All units receive config-changed when application config changes - #73
Open
github-actions[bot] wants to merge 1 commit into
Open
All units receive config-changed when application config changes#73github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
github-actions
Bot
force-pushed
the
probe/issue-72
branch
from
September 7, 2026 02:11
d16ea4b to
2cc1251
Compare
This was referenced Sep 7, 2026
github-actions
Bot
force-pushed
the
probe/issue-72
branch
from
September 7, 2026 02:56
2cc1251 to
5b01690
Compare
Owner
|
PR validates "Who gets it?" for config-changed. https://canonical.com/juju/docs/juju-cli/3.6/reference/hook/#config-changed |
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.
Issue
#72 asks: when a charm has a config option and multiple units, does a config change fire
config-changedon every unit, or is it the leader's responsibility to propagate the change to other units?Claim under test
Claim: When application config changes, Juju fires the
config-changedevent on every unit of the application — not just the leader. It is not the leader's job to propagate config to peers.My understanding (independent of the docs)
Juju treats application config as shared state visible to all units. When config is changed via
juju config, Juju firesconfig-changedindependently on each unit. This is a fundamental Juju behaviour, not something the charm framework or leader election mediates. I therefore expect that after a config change, every unit's charm code runs itsconfig-changedhandler, and any per-unit observable set by that handler (such as the unit workload status message) will be updated on every unit.What I changed
I modified the kepler charm (the only charm touched, so only kepler's CI runs):
src/charm.py: added aconfig-changedobserver and a shared_update_status()helper. Both thepebble-readyandconfig-changedhandlers now set the unit status toActiveStatus(f"log-level={config}"). This makes "did this unit get config-changed?" observable per-unit viajuju status. Both handlers derive the message from the same config value, so neither clobbers the other.tests/unit/test_charm.py: updated the existingtest_pebble_layerto expect the new status message, and added two new unit tests:test_config_changed_updates_status— verifies the config-changed handler sets the status.test_config_changed_survives_pebble_ready— sequence test firingconfig-changedthenpebble-ready, asserting the status message survives the full sequence (defends against event-interaction bugs).tests/integration/test_charm.py:test_deploynow deploys withnum_units=2. Addedtest_all_units_get_config_changed, which changeslog-leveltodebug, waits until every unit's workload status message readslog-level=debug, then asserts both units report the new value.How the test engages the claim
The integration test deploys two units, then changes the
log-levelconfig. The charm'sconfig-changedhandler sets the unit status message tolog-level=<value>. The test uses a customjuju.waitready condition (_all_units_report) that does not return until every unit's workload status message islog-level=debug— not merely until agents are idle. This eliminates any race wherejuju.waitreturns beforeconfig-changedis processed.config-changed(the claim), both units update their status message, the wait condition is satisfied, and the assertions pass → CI passes, claim validated.config-changed, the non-leader's status message never changes, the wait condition is never satisfied,juju.waittimes out, and the test fails → CI fails, claim refuted.Test design review
config-changed, fired byjuju config.log-level=debug)._on_config_changedand_on_demo_server_pebble_ready— both call_update_status(), which derives the message from the same config value.juju config, onlyconfig-changedfires on each unit;pebble-readydoes not re-fire (the container is already running). No later handler clobbers the observable.pebble-readydid fire afterconfig-changed, it sets the same message (same config value). The companion unit testtest_config_changed_survives_pebble_readyconfirms this inrun_tox.run_tox result
tox -e format,lint,unitpasses for kepler: 3 unit tests pass, lint and format clean, pyright reports 0 errors. The integration test imports and type-checks cleanly; CI will run it against a real Juju controller.