Skip to content

backport: feat(pro): manage the ubuntu-advantage charm from the manifest and store enable --manifest - #1047

Open
vsz-work wants to merge 2 commits into
canonical:stable/2025.1from
vsz-work:2025.1/lp2174604-pro-contract-url
Open

vsz-work wants to merge 2 commits into
canonical:stable/2025.1from
vsz-work:2025.1/lp2174604-pro-contract-url

Conversation

@vsz-work

@vsz-work vsz-work commented Nov 25, 2026 •

Copy link
Copy Markdown
Commit Cherry-picked from Change
feat(pro): set the ubuntu-advantage charm channel, revision and config from the manifest 03ffd06d (#1032), as adapted in #1039 Manifest passthrough for the pro charm's channel, revision and config. The CLI token always wins over a token key in the manifest
fix(pro): store the manifest passed to sunbeam enable --manifest <file> pro 63bfa2b2 (#1032), as in #1039 enable --manifest stores the file as the latest manifest, so later enable pro runs keep the settings

Adaptations for 2025.1

None beyond the 2024.1 ones. stable/2025.1 has the same pro feature, plan and tests as stable/2024.1: the deploy-pro plan still deploys the ubuntu-advantage charm, and #1020 (switch to ubuntu-pro) is only on main. So these are #1039's commits, cherry-picked unchanged. They apply cleanly; only the "Backport notes" paragraph in the first commit message now names 2025.1. As in #1039:

  • Manifest key ubuntu-advantage (the CHARM constant), not ubuntu-pro. The Juju application is still named ubuntu-pro, but sunbeam cluster refresh looks manifest entries up by the deployed charm name (find_charm), so the key has to match the charm.
  • Tfvars: ubuntu-advantage-channel (existing), plus new ubuntu-advantage-revision and ubuntu-advantage-config.
  • Default channel latest/edge (UBUNTU_ADVANTAGE_CHANNEL), the existing default of the plan's channel variable, so existing deployments don't move channel.

The code the backport relies on (AddManifestStep, validate_charm_keys, find_charm in the in-channel refresh, manifest_attributes_tfvar_map, enable --manifest) is the same on 2025.1 as on 2024.1. The only differences between the two branches in that area are unrelated: a TLS re-provision step in refresh.py that only 2024.1 has, and an import typo fix in main.py.

Manifest example on 2025.1:

features:
  pro:
    software:
      charms:
        ubuntu-advantage:
          config:
            contract_url: https://contracts.example.com

Why 2025.1 needs it too

The bug targets 2024.1, 2026.1 and main, but 2025.1 is a current stable series and has the same gap. There's also an upgrade dependency on #1039: Sunbeam validates the stored manifest's charm keys on every command. A 2024.1 deployment that stores an ubuntu-advantage entry (possible once #1039 lands) and is upgraded to a 2025.1 snap without this backport would fail every command that loads the manifest with Manifest Software charms keys should be one of …. With this backport, 2024.1 → 2025.1 keeps working because both use the same key.

Caveats (same as #1039)

QA steps

Unit tests:

cd sunbeam-python
tox -e py3 -- tests/unit/sunbeam/features/test_pro.py
tox -e pep8 && tox -e mypy

On a 2025.1 single-node deployment, with a snap built from this branch:

sunbeam manifest show latest > base.yaml
yq -y '.features.pro.software.charms["ubuntu-advantage"].config.contract_url = "https://contracts.canonical.com/"' base.yaml > pro.yaml
sunbeam enable --manifest pro.yaml pro <token>
juju config -m openstack-machines ubuntu-pro contract_url   # https://contracts.canonical.com/

sunbeam enable pro <token>                                   # no --manifest
juju config -m openstack-machines ubuntu-pro contract_url   # still the manifest value
sudo pro status --format json | jq .attached                 # true

Tested

Check Result
Unit suite on stable/2025.1 + this branch 4411 passed. ruff format, ruff check and mypy sunbeam are clean
terraform fmt -check and terraform validate on deploy-pro Done
C1. Enable with no pro config ✅ ubuntu-advantage latest/edge rev 147, as before; tfvars ubuntu-advantage-channel: latest/edge, no -config; contract_url is the charm default
C2. contract_url from --manifest (key ubuntu-advantage) ✅ Tfvars ubuntu-advantage-config; juju config and uaclient.conf show the value; the charm re-attached; attached
C3. Re-enable without --manifest ✅ The stored manifest holds the ubuntu-advantage entry; the value is kept
C4. A token key in the manifest config ✅ Ignored: Juju holds the CLI token
C5. Option removed from the manifest ✅ contract_url back to the charm default
C6. Unknown option name ✅ enable pro fails: unknown option "contrct_url"; the unit stays active and attached
C7. Redeploy on latest/stable, then cluster refresh to latest/edge ✅ Fresh deploy on latest/stable rev 143 from the manifest. Refresh with no pro section found the default entry (Running refresh for app ubuntu-pro with manifest config): rev 143 → latest/edge rev 147, upgrade-charm + config-changed, no detach. CLI token kept; attached; stored manifest has no pro section
C8. enable pro after the refresh ✅ Tfvars latest/edge; Apply complete! Resources: 0 added, 0 changed, 0 destroyed; charm unchanged; attached
C9. Disable ✅ "Ubuntu Pro disabled."; no ubuntu-pro app or juju-info relation left. Needs #1023

Sunbeam VM run (2026-11-25):

C2, tfvars written by Sunbeam (token removed) and the charm's log:

{ "ubuntu-advantage-config": { "contract_url": "https://contracts.canonical.com/" }, "machine_model_uuid": "…" }
unit-ubuntu-pro-0: 19:33:33 INFO unit.ubuntu-pro/0.juju-log Updating uaclient.conf
unit-ubuntu-pro-0: 19:33:40 INFO unit.ubuntu-pro/0.juju-log Detaching ubuntu-advantage subscription
unit-ubuntu-pro-0: 19:33:51 INFO unit.ubuntu-pro/0.juju-log Attaching to new subscription with services: None

C7b, refresh from latest/stable to the default latest/edge:

{"charm":"ubuntu-advantage","channel":"latest/stable","rev":143}   # before
{"charm":"ubuntu-advantage","channel":"latest/edge","rev":147}     # after
sunbeam.steps.upgrades.intra_channel DEBUG Running refresh for app ubuntu-pro with manifest config
unit-ubuntu-pro-1: 19:42:38 INFO juju.worker.uniter.operation ran "upgrade-charm" hook
unit-ubuntu-pro-1: 19:42:49 INFO juju.worker.uniter.operation ran "config-changed" hook
{"attached":true,"services":["esm-apps","esm-infra","livepatch"]}

Full trimmed evidence: attached lp2174604-2025.1-qa.pr.txt.

The behaviour was also tested end to end on main in #1032 (T1–T10) and on 2024.1 in #1039 (B1–B10).

Links

Jira card: OPEN-XXXX

…g from the manifest

The deploy-pro plan only set the token on the ubuntu-advantage charm, so
contract_url and the other charm options kept their defaults. The only
way to change them was a manual `juju config`, which Sunbeam does not
own and can lose on a later apply or redeploy.

Register the ubuntu-advantage charm in the pro feature's default
software config, with UBUNTU_ADVANTAGE_CHANNEL (latest/edge, the
existing plan default) as its channel, and map its channel, revision
and config to new or existing plan variables, as other features do:

- ubuntu-advantage-channel (existing)
- ubuntu-advantage-revision (new, default null)
- ubuntu-advantage-config (new, map(string), default {})

Any charm option can now be set in the manifest, for example:

  features:
    pro:
      software:
        charms:
          ubuntu-advantage:
            config:
              contract_url: https://contracts.example.com

The plan merges the manifest config under the token passed on the
command line, so the CLI token always wins over a token key in the
manifest.

Backport notes: stable/2025.1, like stable/2024.1, still deploys the
ubuntu-advantage charm (the switch to ubuntu-pro is only on main), so
the manifest key, tfvars and default channel use the ubuntu-advantage
names. The new CHARM constant holds the charm name, which differs from
the ubuntu-pro application name; refresh looks manifest entries up by
charm name. The ubuntu-pro plan tests from main are not included.

Jira: OPEN-4937
Assisted-By: Claude Code (Claude Opus 5.5)
Related-Bug: #2174604
(cherry picked from commit 03ffd06)
Signed-off-by: Vítor Zeni <vitor.zeni@bairesdev.com>
…le> pro`

The pro feature never stored a manifest given with --manifest. The file
only applied to that one run, and a later `sunbeam enable pro <token>`
read the latest manifest from clusterd, fell back to an empty charm
config and dropped options such as contract_url again.

Start the enable plan with AddManifestStep when --manifest is given, as
the OpenStack features and telemetry already do. Like for those
features, the file is stored as the whole latest manifest, so it should
be a full manifest (e.g. from `sunbeam manifest show latest`) with the
pro section added, not a pro-only file.

Without --manifest the plan is unchanged.

Jira: OPEN-4937
Assisted-By: Claude Code (Claude Opus 5.5)
Closes-Bug: #2174604
Signed-off-by: Vítor Zeni <vitor.zeni@bairesdev.com>
(cherry picked from commit 63bfa2b)
@vsz-work vsz-work changed the title 2025.1/lp2174604 pro contract url backport: feat(pro): manage the ubuntu-advantage charm from the manifest and store enable --manifest Nov 25, 2026
@vsz-work vsz-work changed the title backport: feat(pro): manage the ubuntu-advantage charm from the manifest and store enable --manifest backport: feat(pro): manage the ubuntu-advantage charm from the manifest and store enable --manifest Nov 25, 2026
@vsz-work
vsz-work marked this pull request as ready for review November 25, 2026 19:57
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.

1 participant