Fix content-cache-k8s hanging in maintenance when nginx-proxy is consumed via CMR - #194
Open
florentianayuwono with Copilot wants to merge 3 commits into
Open
Fix content-cache-k8s hanging in maintenance when nginx-proxy is consumed via CMR#194florentianayuwono with Copilot wants to merge 3 commits into
florentianayuwono with Copilot wants to merge 3 commits into
Conversation
…lations
In a Cross-Model Relation (CMR), remote unit names follow the pattern
remote-<uuid>/<n> (Juju-internal proxy tokens), not real Kubernetes pod
names. The previous code used these tokens to construct headless pod DNS
entries that don't exist in the remote namespace.
Detect CMR proxy units by checking for the remote- prefix on unit names,
then use Kubernetes service-level DNS with the service-namespace from the
relation app data (set by NginxRouteRequirer to the requirer's model name):
http://{svc_name}.{svc_namespace}.svc.cluster.local:{svc_port}
This lets nginx correctly resolve and proxy to the backend service in the
remote Juju model on the same Kubernetes cluster.
Closes #193
Co-authored-by: florentianayuwono <76247368+florentianayuwono@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix content-cache-k8s hanging in maintenance during config update
Fix content-cache-k8s hanging in maintenance when nginx-proxy is consumed via CMR
Jul 7, 2026
Co-authored-by: florentianayuwono <76247368+florentianayuwono@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes content-cache-k8s getting stuck in maintenance: Updating pebble layer config when the nginx-proxy relation is established via Juju Cross-Model Relations (CMR), where remote units are represented as remote-<uuid>/<n> and cannot be used to construct pod-level headless DNS names.
Changes:
- Update
_make_env_configto detect CMR proxy unit names (remote-...) and, when detected, build a service-level Kubernetes DNS backend URL usingservice-name,service-namespace(fallback to local model name), andservice-port. - Preserve existing same-model behavior that builds pod-level headless DNS entries from unit names.
- Add unit tests validating the service-level DNS behavior for CMR (with and without
service-namespacepresent).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/charm.py |
Adds CMR detection and switches backend URL construction to service-level DNS for CMR relations. |
tests/unit/test_charm.py |
Adds unit tests covering CMR proxy relations and the service-namespace fallback behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a Cross-Model Relation (CMR), Juju represents remote units with proxy names like
remote-<uuid>/0instead of real application unit names. The charm was using these tokens to build headless pod DNS entries (remote-<uuid>-0.<svc>-endpoints.<local-model>.svc.cluster.local) that don't exist, causing nginx to fail on startup and leaving the unit stuck inmaintenance: Updating pebble layer config.What this PR does
_make_env_configby checking for theremote-prefix on unit namesservice-namespacecomes from the relation app data (automatically populated byNginxRouteRequirerwith the requirer's model name); falls back to the local model name if absentWhy we need it
Cross-model relations are a standard Juju capability. CMR deployments were completely broken — the charm would never reach
activeand the hook would fail on every retry.Checklist
docs/changelog.mdwith user-relevant changesdocs/release-notes/artifacts. If no change artifact is necessary, I tagged the PR with the labelno-release-note.(e.g., in
.github/workflows/integration_tests.yaml, ensure themoduleslist is correct)Test plan
Two new unit tests added:
test_make_env_config_with_cmr_proxy_relation— verifies service-level DNS withservice-namespacepresenttest_make_env_config_with_cmr_proxy_relation_no_namespace— verifies fallback to local model name whenservice-namespaceis absentReview focus
The CMR detection heuristic (
unit.name.startswith("remote-")) matches Juju's documented naming convention for CMR proxy units. No Juju API exists to query this directly, so the prefix check is the standard approach.