Skip to content

refactor(garm-configurator): define required relation fields (ISD-7629) - #468

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

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

Conversation

@Thanhphan1147

@Thanhphan1147 Thanhphan1147 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Defines the required and optional fields of the garm-configurator relation and enforces the contract from both sides.

  • The shared garm_configurator_relation models now mark the provider and scaleset fields that block provider, credential, or scaleset creation as required and reject blank values. Required provider fields are the OpenStack URL/user/project/domains/region/network, the GitHub App ids and private-key secret URI, and a password source. Required scaleset fields are the name, provider name, image, flavor, architecture, and exactly one of org or repo.
  • Optional scaleset fields keep GARM's defaults (min_idle_runner="0", max_runner="1", runner_group="Default", and so on) instead of defaulting to an empty string.
  • garm-configurator publishes its relation payload only when every required value, including the image, is available. While the image builder has not supplied an image, it withdraws any older payload rather than writing an incomplete one. If a required config value is missing, the charm blocks before writing.
  • garm continues to mark a relation with an incomplete or malformed payload as invalid and blocks rather than rendering a partial provider or scaleset.
  • Documents the required/optional split in the charm reference and adds a changelog entry.

This is the relation-contract part of ISD-7629 (spec reference: ISD303). LXD provider support itself remains out of scope.

Why we need it

The relation databag previously gave every field an empty-string default, so neither side could tell which fields actually gate provider or scaleset creation. An incomplete payload could look valid, and the configurator could publish a scaleset without an image. Making the blocking fields required, and the fields with sensible defaults explicitly optional, gives the two charms one clear contract.

Test plan

  • tox -c tox.toml -e unit in charms/garm-configurator — 97 passed.
  • tox -c tox.toml -e fmt,lint,complexity,static in charms/garm-configurator — all pass.
  • tox -c tox.toml -e unit in charms/garm — 480 passed, recreated against the bumped relation-library pin.
  • tox -c tox.toml -e fmt,lint,complexity,static in charms/garm — all pass.
  • tox -c tox.toml -e coverage-report in both charms — garm-configurator 96% total.
  • make -C docs spellcheck — 0 errors.
  • go test ./... — all packages pass.
  • Unit tests are scoped to the models/methods; configurator behaviour is covered with Scenario. No new integration test: the change is the unit-testable relation contract, and the existing configurator → garm integration already exercises the end-to-end flow.

Review focus

  • Withholding the relation payload while the image is unavailable changes the previous "publish an empty image_id to remove the scaleset" behaviour. GARM now treats the relation as waiting and keeps its existing provider and scalesets until a complete payload is republished. This follows the ticket's requirement that required values must not be published empty.
  • The password is required as either the inline openstack_password (kept for backwards compatibility) or openstack_password_secret_uri; the configurator publishes the secret URI.
  • The relation-library pin points at eef25b8 from this branch, so CI installs the updated shared package.

Potential breaking changes

  • A garm-configurator payload that omits a now-required field, or carries a blank value for one, is invalid and makes the GARM charm block instead of creating a partial provider or scaleset.
  • Withdrawing the image no longer publishes an empty image to remove the scaleset; the configurator withdraws its payload instead.

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 (see docs/reference/charms.md and docs/changelog.md)
  • I updated docs/changelog.md with user-relevant changes
  • I used AI to assist with preparing this PR
  • I added or updated tests as needed (unit and scenario tests)
  • 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 the upstream copilot-collections guidance (not applicable)

@Thanhphan1147
Thanhphan1147 force-pushed the houston/ISD-7628 branch 2 times, most recently from 290ca55 to 9f23019 Compare November 19, 2026 15:16
…ion (ISD-7629)

Mark the provider and scaleset fields that block provider, credential, or
scaleset creation as required in the shared relation model, rejecting blank
values, and give the optional fields GARM's defaults. The configurator now
publishes nothing until every required value, including the image, is
available, withdrawing an older payload instead of writing an incomplete one.
…7629)

Publish the newly required provider and scaleset fields in the garm unit
fixtures, treat a payload missing a required field as an invalid relation,
and bump the shared relation-library pin. Document the required fields and
the configurator's publish-only-when-complete behaviour.
logger = logging.getLogger(__name__)


def _reject_blank(value: str, info: pydantic.ValidationInfo) -> str:

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.

Update the name to validate_field_not_empty

Comment on lines +173 to +175
if state.image is None:
self._withdraw_garm_relation(garm_relation)
return

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.

Dont clear the relation data here, as misconfiguring can happen and that'll break a working deployment. We need to validate new changes but never wipe old data if the new data is invalid

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

Active issues remain because whitespace-only credentials and entity fields are accepted, and withdrawing one configurator’s databag can delete existing provider and scaleset resources despite the intended preservation behavior.

3 open issues
What changed in this PR

This PR formalizes the garm-configurator relation contract so provider and scaleset payloads cannot be created from incomplete required fields. It updates both charms, shared relation models, tests, dependency pinning, and documentation.

Changes:

  • Marks provider and scaleset fields as required, validates relation payloads, and applies explicit defaults to optional fields.
  • Makes the configurator withhold or withdraw relation data until a complete payload, including an image, is available.
  • Updates GARM/configurator tests, documentation, changelog, and the shared relation-library pin.
File Description
docs/​reference/​charms.md Documents the required and optional configurator relation fields and behavior.
docs/​changelog.md Records the relation-contract and image-publication changes.
charms/​garm/​tests/​unit/​test_charm.py Updates GARM tests for invalid relation payloads and missing images.
charms/​garm/​tests/​unit/​test_charm_state.py Adapts relation-state fixtures and tests to the stricter shared models.
charms/​garm/​requirements.txt Pins the GARM charm to the updated shared relation-library revision.
charms/​garm-configurator/​tests/​unit/​test_garm_configurator_relation.py Adds coverage for required fields, defaults, entity exclusivity, and invalid payload handling.
charms/​garm-configurator/​tests/​unit/​test_charm.py Tests complete-payload publication and withdrawal behavior when images are unavailable.
charms/​garm-configurator/​src/​charm.py Publishes complete relation data and withdraws payloads when required values, including the image, are unavailable.
charms/​garm-configurator/​lib/​garm_configurator_relation.py Defines the shared provider and scaleset relation models, validation rules, and optional defaults.

Review effort: Lite

Comment on lines +173 to +175
if state.image is None:
self._withdraw_garm_relation(garm_relation)
return
Comment on lines +121 to +124
if not (self.openstack_password or self.openstack_password_secret_uri):
raise ValueError(
"one of openstack_password or openstack_password_secret_uri is required"
)
Comment on lines +209 to +210
if bool(self.org) == bool(self.repo):
raise ValueError("exactly one of org or repo is required")

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.

2 participants