feat!: only provide the Juju default databag keys while the charm runs - #2637
Draft
tonyandrewmeyer wants to merge 4 commits into
Draft
feat!: only provide the Juju default databag keys while the charm runs#2637tonyandrewmeyer wants to merge 4 commits into
tonyandrewmeyer wants to merge 4 commits into
Conversation
Relation databags (`local_unit_data`, `remote_units_data`, `remote_unit_data`) now default to empty dicts. Just before the charm runs, Scenario injects the keys Juju itself auto-populates (`egress-subnets`, `ingress-address`, and on Juju 3 `private-address`) into every unit databag, and they flow through to the output state. This is the backwards-incompatible alternative to canonical#2618: instead of stripping `private-address` from the construction default when the mocked Juju version is 4+, Scenario now matches Juju's own behaviour and only inserts the keys the real Juju would insert. Tests that read a `Relation`'s databag before running the charm will see empty dicts. Fixes canonical#2185. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The keys that Juju manages itself (`egress-subnets`, `ingress-address`, and on Juju 3 `private-address`) are injected into every relation unit databag just before the charm runs, and removed again before the output state is returned, so the output state has the same shape as the input one. A key that the charm wrote to while it was running is left in place. The values now come from the `Network` for the relation's endpoint, as they do in Juju: `ingress-address` (and `private-address`) is the first ingress address, and `egress-subnets` is the comma-separated list of egress subnets. With the default network that means `egress-subnets` is now `192.0.2.0/24` rather than `192.0.2.0`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DdyoibByxhQVcn65aavYfs
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.
Relation databags (
local_unit_data,remote_units_data,remote_unit_data) now default to empty dicts. While the charm is running, Scenario adds the keys that Juju manages itself (egress-subnets,ingress-address, and on Juju 3private-address) to every unit databag, and removes them again before the output state is returned, so that the output state has the same shape as the input one. A key that the charm wrote to while it was running is left in place.The values come from the
Networkfor the relation's endpoint, the way Juju does it:ingress-address(andprivate-address) is the first ingress address, andegress-subnetsis the comma-separated list of egress subnets. With the default network that meansegress-subnetsis now192.0.2.0/24rather than192.0.2.0. I checked this against 3.6.27 and 4.0.12 on LXD, and in both the databag values matchnetwork-getexactly (egress-subnets: 10.5.87.59/32,ingress-address: 10.5.87.59), with 4.0 not settingprivate-addressat all.This is the backwards-incompatible alternative to #2618: instead of stripping
private-addressfrom the construction default when the mocked Juju version is 4+, Scenario provides the keys that the real Juju would provide, sort-of for as long as it would provide them.Fixes #2185.