Skip to content

refactor(garm-configurator): nest provider and scaleset relation data (ISD-7628) - #467

Open
Thanhphan1147 wants to merge 2 commits into
houston/ISD-7626from
houston/ISD-7628
Open

Thanhphan1147 wants to merge 2 commits into
houston/ISD-7626from
houston/ISD-7628

Conversation

@Thanhphan1147

@Thanhphan1147 Thanhphan1147 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Splits the garm-configurator relation application databag into two nested values instead of one flat set of keys:

application-data:
  garm-configurator:
    provider:
      openstack_auth_url: ...
      github_app_id: ...
    scaleset:
      name: ...
      provider_name: ...
      flavor: ...
  • garm-configurator now publishes ConfiguratorApplicationData(provider=..., scaleset=...) with a single ops.Relation.save.
  • The shared relation library separates ProviderConfig (provider and GitHub App credentials) from ScalesetConfig (scaleset and runner fields), and the requirer loads the nested payload back into a ConfiguratorRelation.
  • provider_name now lives in the nested scaleset value, matching GARM's scaleset model.
  • The garm charm continues to consume the same ConfiguratorRelation / ScalesetConfig views; 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 provider and scaleset objects 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 unit in charms/garm-configurator — all pass.
  • tox -e lint -e complexity -e static -e unit in charms/garm — all pass.
  • tox -e coverage-report in both charms (garm-configurator: 96% total).
  • Unit tests assert the actual ops.Relation.save output has exactly the provider and scaleset keys, 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.
  • No integration test added: the existing garm integration 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

  • The wire format is intentionally new: provider_name moved from the provider payload into scaleset because it is a GARM scaleset field. Both charms and the shared library are updated in this branch.
  • _decode_relation_value was removed; it existed only for the old flat format, which never shipped on the application databag.
  • The garm requirements 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 → garm relation contract, and both sides ship together. No configuration options changed.

Checklist

  • Changes comply with the project's coding standards and guidelines (see CONTRIBUTING.md and STYLE.md)
  • CONTRIBUTING.md has been updated upon changes to the contribution/development process (not applicable)
  • Technical author has been assigned to review the PR in case of documentation changes (not applicable)
  • I updated docs/changelog.md with user-relevant changes (internal relation contract, not user-facing)
  • I used AI to assist with preparing this PR
  • I added or updated tests as needed (unit and integration)
  • If integration test modules are used: I updated the workflow configuration (not applicable)
  • If this PR involves a Grafana dashboard: I added a screenshot of the dashboard (not applicable)
  • If this PR involves Terraform: terraform fmt passes and tflint reports no errors (not applicable)
  • If this PR involves Rockcraft: I updated the version (not applicable)
  • If this PR adds/removes a charm, or changes a charm's base class, conventions, tooling, or repo structure: I updated the relevant AGENTS.md (not applicable)
  • If this PR changes .copilot-collections.yaml or .github/instructions/: I re-checked whether the AGENTS.md "12-factor divergences" guidance still matches (not applicable)

… (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.


@pydantic.dataclasses.dataclass
class ConfiguratorApplicationData:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the name to ProviderApplicatData

Comment on lines +78 to +119
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"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this new test as it's not testing anything new

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 provider and scaleset relation payloads.
  • Moved provider_name into 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.
@weiiwang01

Copy link
Copy Markdown
Collaborator

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?

@Thanhphan1147

Copy link
Copy Markdown
Contributor Author

@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 ... )

This branch has not been deployed

No deployments
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.

3 participants