Repository navigation
refactor(garm-configurator): nest provider and scaleset relation data (ISD-7628) - #467
Thanhphan1147 wants to merge 2 commits into
Conversation
5243fb2 to
e7fff47
Compare
40fbb15 to
290ca55
Compare
e7fff47 to
f3f0e67
Compare
… (ISD-7628) Publish the garm-configurator application databag as nested provider and scaleset values instead of one flat set of keys, so consumers parse the provider credentials and the scaleset fields independently.
Update the garm unit tests to publish the configurator application databag as nested provider and scaleset values, and bump the shared relation library pin to the refactor commit.
290ca55 to
9f23019
Compare
|
|
||
|
|
||
| @pydantic.dataclasses.dataclass | ||
| class ConfiguratorApplicationData: |
There was a problem hiding this comment.
Change the name to ProviderApplicatData
| def test_application_data_nests_provider_and_scaleset(): | ||
| """ | ||
| arrange: A complete configurator payload with provider credentials and scaleset fields. | ||
| act: Serialise it the way ``ops.Relation.save`` does. | ||
| assert: The databag has one ``provider`` object and one ``scaleset`` object, each holding | ||
| only its own fields, so consumers parse the two concerns separately. | ||
| """ | ||
| application_data = ConfiguratorApplicationData( | ||
| provider=ProviderConfig( | ||
| openstack_auth_url="https://ks.example.com:5000/v3", | ||
| github_app_id=123, | ||
| ), | ||
| scaleset=ScalesetConfig( | ||
| name="my-scaleset", | ||
| provider_name="configurator-0", | ||
| image_id="ubuntu:24.04", | ||
| max_runner="6", | ||
| ), | ||
| ) | ||
|
|
||
| nested = dataclasses.asdict(application_data) | ||
|
|
||
| assert set(nested) == {"provider", "scaleset"} | ||
| assert nested["provider"] == { | ||
| "openstack_auth_url": "https://ks.example.com:5000/v3", | ||
| "openstack_username": None, | ||
| "openstack_password": None, | ||
| "openstack_password_secret_uri": None, | ||
| "openstack_project_name": None, | ||
| "openstack_user_domain_name": None, | ||
| "openstack_project_domain_name": None, | ||
| "openstack_region_name": None, | ||
| "openstack_network": None, | ||
| "github_app_id": 123, | ||
| "github_installation_id": None, | ||
| "github_private_key_secret_uri": None, | ||
| } | ||
| assert nested["scaleset"]["name"] == "my-scaleset" | ||
| assert nested["scaleset"]["provider_name"] == "configurator-0" | ||
| assert nested["scaleset"]["max_runner"] == "6" | ||
| assert "name" not in nested["provider"] | ||
| assert "openstack_auth_url" not in nested["scaleset"] |
There was a problem hiding this comment.
Remove this new test as it's not testing anything new
There was a problem hiding this comment.
🟡 Changes recommended
A critical upgrade-compatibility issue remains: existing legacy application databags can become unreadable and block GARM updates, alongside a minor inaccurate test description.
2 open issues
What changed in this PR
Refactors the internal garm-configurator → garm relation contract so provider credentials and scaleset configuration are published as separate nested application-databag values, with both charms and the shared relation library updated together.
Changes:
- Added nested
providerandscalesetrelation payloads. - Moved
provider_nameinto the scaleset configuration. - Updated publishers, consumers, dependency pinning, and test fixtures for the new wire format.
- A rolling-upgrade compatibility issue remains for existing flat relation data.
| File | Description |
|---|---|
| charms/garm/tests/unit/test_charm.py | Updates GARM unit-test fixtures and scenarios to use nested provider and scaleset relation data. |
| charms/garm/requirements.txt | Pins GARM to the shared relation library revision supporting the nested relation schema. |
| charms/garm-configurator/tests/unit/test_garm_configurator_relation.py | Tests nested relation serialization and requirer access to provider and scaleset data. |
| charms/garm-configurator/tests/unit/test_charm.py | Updates configurator publisher tests and assertions for the nested relation payload. |
| charms/garm-configurator/src/charm.py | Builds and saves the nested provider and scaleset application relation payload. |
| charms/garm-configurator/lib/garm_configurator_relation.py | Defines the nested relation models and loads provider and scaleset data through the requirer. |
Review effort: Lite
| provider = relation.load( | ||
| ProviderConfig, application, decoder=_decode_relation_value | ||
| ) | ||
| application_data = relation.load(ConfiguratorApplicationData, application) |
| act: config-changed fires. | ||
| assert: org, runner_group, and pre_install_scripts are present in the | ||
| garm relation data. repo is published as an empty string. | ||
| garm relation data. repo is absent. |
|
I think this change is not backward compatible with the old version of the GARM/garm-configurator? Is there a plan to keep backward compatibility, or will this require a coordinated upgrade to upgrade them simultaneously? |
|
@weiiwang01 yes this won't be backwards compatible because with the changes I had in mind would be too complex to keep backward compatibility so most changes were made were breaking ( like changing where relation data is written, changing to app data, using ops.relation.save, etc ... ) |


What this PR does
Splits the
garm-configuratorrelation application databag into two nested values instead of one flat set of keys:garm-configuratornow publishesConfiguratorApplicationData(provider=..., scaleset=...)with a singleops.Relation.save.ProviderConfig(provider and GitHub App credentials) fromScalesetConfig(scaleset and runner fields), and the requirer loads the nested payload back into aConfiguratorRelation.provider_namenow lives in the nestedscalesetvalue, matching GARM's scaleset model.garmcharm continues to consume the sameConfiguratorRelation/ScalesetConfigviews; only the shared library pin and the test fixtures that build relation data changed.Why we need it
Both concerns were mixed in one flat dict, so every consumer had to know which keys belonged to the provider and which to the scaleset. Nested
providerandscalesetobjects make the contract easier to parse and give the forthcoming LXD provider work a natural place to add provider-specific fields.Part of ISD-7628 (spec reference: ISD303). This PR only does the relation-data split; LXD provider support itself remains out of scope.
Test plan
tox -e lint -e complexity -e static -e unitincharms/garm-configurator— all pass.tox -e lint -e complexity -e static -e unitincharms/garm— all pass.tox -e coverage-reportin both charms (garm-configurator: 96% total).ops.Relation.saveoutput has exactly theproviderandscalesetkeys, that each object holds only its own fields, and that the requirer loads both nested values. Existing garm tests were updated to publish nested fixtures, covering provider credentials, scaleset fields, runner options, conflicts, and incomplete relations.garmintegration test already exercises the configurator → garm flow end to end, and the wire-format change is fully covered by the unit tests above.Review focus
provider_namemoved from the provider payload intoscalesetbecause it is a GARM scaleset field. Both charms and the shared library are updated in this branch._decode_relation_valuewas removed; it existed only for the old flat format, which never shipped on the application databag.garmrequirements pin points at the library commit from this branch (1a68829), so CI can install the updated relation package.Potential breaking changes
None for users. This changes the internal
garm-configurator→garmrelation contract, and both sides ship together. No configuration options changed.Checklist
CONTRIBUTING.mdhas been updated upon changes to the contribution/development process (not applicable)docs/changelog.mdwith user-relevant changes (internal relation contract, not user-facing)terraform fmtpasses andtflintreports no errors (not applicable)AGENTS.md(not applicable).copilot-collections.yamlor.github/instructions/: I re-checked whether theAGENTS.md"12-factor divergences" guidance still matches (not applicable)