Skip to content

Merge 4.0 into main - #138

Merged
SimonRichardson merged 31 commits into
juju:mainfrom
SimonRichardson:merge-4.0-into-main-2
Aug 27, 2026
Merged

Merge 4.0 into main#138
SimonRichardson merged 31 commits into
juju:mainfrom
SimonRichardson:merge-4.0-into-main-2

Conversation

@SimonRichardson

@SimonRichardson SimonRichardson commented Aug 27, 2026

Copy link
Copy Markdown
Member

6f53c32 (upstream/4.0) Merge pull request #133 from gfouillet/gh130-metrics-endpoint-k8s-bind-fqdn
951c97b (origin/4.0, merge-4.0-into-main, 4.0) Merge pull request #132 from manadart/4.0-handle-cluster-depart
f2cc29f Merge pull request #131 from manadart/4.0-pydantic
08518b2 Merge pull request #128 from wallyworld/merge-3.6
7b94ff6 (upstream/main, origin/main, main) Merge pull request #124 from SimonRichardson/loki-alert-rules
8b8c3a8 Merge pull request #123 from SimonRichardson/remove-prefixes-for-config
36e9985 Merge pull request #118 from SimonRichardson/loki
ebf3e5c Merge pull request #120 from SimonRichardson/workload-tracing
9997bfc Merge pull request #121 from juju/merge-3.6
8958844 Merge pull request #107 from SimonRichardson/s3-integrator
1dd870d Merge pull request #116 from SimonRichardson/4.0-into-main-1
f97f1d8 Merge pull request #100 from juju/4.0-into-main
e6ca859 Merge pull request #97 from juju/4.0
8666e15 Merge pull request #94 from gfouillet/v4/chore/bump-4.1

Abuelodelanada and others added 30 commits November 27, 2025 15:22
use correct `ca` key in prometheus scrape_job
Uses uv for dependencies, streamlining builds.
feat: back-port PR juju#98 from 4.0 branch
…e/observability"

This reverts commit 95d29e5, reversing
changes made to abb5f63.
Needs chaermcraft 4.x to work with 26.04.
Have only the application leader create and reconcile one controller metrics user shared by all Prometheus relations, while non-leaders publish only their unit addresses. Persist the credential in relation data so retries, leadership changes, and upgrades reuse the same identity, and clean it up after the final relation is removed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merge pull request juju#127 from jameinel/fix/3.6-prometheus-metrics-user-ha

Have only the application leader create and reconcile one controller metrics user shared by all Prometheus relations, while non-leaders publish only their unit addresses. Persist the credential in relation data so retries, leadership changes, and upgrades reuse the same identity, and clean it up after the final relation is removed.

The previous logic just tried to create the metrics user on every unit, which meant that they would collide and fail. This, instead, has the lead unit create the user, and record that in the relation data. Which then allows for the next leader unit to see if the user has already been created.
This moves forward to a version that has the requisite binary wheel for
riscv64.
If removing the leader unit from a HA controller deployment, it can get
departed events from other units. It should not reconfigure the cluster
if it is one leaving, otherwise the other units can end up wedged with a
cluster config that only has the departed unit.
fix: departing leader should not rewrite cluster addresses
Fix three issues that cause the metrics-endpoint relation hooks to fail
on k8s controllers (JUJU-10266):

1. controlsocket.APIError was never imported — the charm caught
   controlsocket.APIError but APIError lives in unixsocket. Any socket
   error crashed the hook with AttributeError.

2. _ensure_metrics_user only handled HTTP 409; the Juju controller
   returns HTTP 500 (password destroyed) when the user already exists.
   Now catches both 409 and 500, removes the stale user, and recreates
   it cleanly.

3. On k8s, network-get can return a service FQDN instead of an IP for
   bind_address early in the unit lifecycle. The prometheus_scrape
   library calls ipaddress.ip_network() on this value, raising
   ValueError. The charm now catches this, logs a warning, and defers
   the event so it retries when the binding resolves to an IP.

Juju-side fix: https://warthogs.atlassian.net/browse/JUJU-10266
Add two tests covering the untested re-raise branches introduced in
PR juju#133:

- test_metrics_ensure_user_reraises_non_recoverable_error: verifies
  that an APIError with a code not in (409, 500) is re-raised without
  attempting the remove/recreate recovery.
- test_metrics_remove_user_reraises_non_404_error: verifies that a
  non-404 APIError from remove_metrics_user propagates during the
  409-recovery flow.
charm.py now catches controlsocket.APIError (via the re-export added
in the previous commit) rather than importing unixsocket directly.
This keeps charm.py depending on controlsocket as its public interface
and avoids a redundant direct dependency on the underlying socket
module. Tests updated to import APIError from controlsocket for
consistency.
Strengthen test_metrics_endpoint_update_scrape_job_spec_binding_unresolved
by asserting update_scrape_job_spec was actually called after the
ValueError, rather than only verifying no exception escaped.
Add four tests covering previously untested scenarios:

- test_metrics_ensure_user_retry_failure_propagates: verifies that
  when both add_metrics_user calls fail with 500, the second error
  propagates and remove_metrics_user is called exactly once (Mn1).
- test_metrics_endpoint_redefers_until_resolved: verifies that the
  charm keeps deferring while the binding is unresolved and succeeds
  once it resolves (Mn4).
- test_metrics_endpoint_password_stable_across_deferred_retry: verifies
  that the metrics password does not churn across a deferred retry
  even when generate_password would return a different value (Mn5).
- test_controlsocket_reexports_api_error: verifies that
  controlsocket.APIError is unixsocket.APIError (I3).
…-bind-fqdn

fix: handle metrics-endpoint binding and APIError on k8s
@SimonRichardson
SimonRichardson merged commit d3eac34 into juju:main Aug 27, 2026
@SimonRichardson
SimonRichardson deleted the merge-4.0-into-main-2 branch August 27, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants