Repository navigation
feat(pro): manage the ubuntu-pro charm from the manifest and store enable --manifest - #1032
Merged
Merged
Conversation
vsz-work
force-pushed
the
lp2174604-pro-contract-url
branch
from
November 17, 2026 13:36
44d58e4 to
8c64c2b
Compare
vsz-work
marked this pull request as ready for review
November 17, 2026 15:12
gboutry
requested changes
Nov 18, 2026
… the manifest
The deploy-pro plan only set the token on the ubuntu-pro 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-pro charm in the pro feature's default software
config, with UBUNTU_PRO_CHANNEL as its channel, and map its channel,
revision and config to new or existing plan variables, as other
features do:
- ubuntu-pro-channel (existing)
- ubuntu-pro-revision (new, default null)
- ubuntu-pro-config (new, map(string), default {})
Any charm option can now be set in the manifest, for example:
features:
pro:
software:
charms:
ubuntu-pro:
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.
Jira: OPEN-4937
Assisted-By: Claude Code (Claude Opus 5.5)
Related-Bug: #2174604
Signed-off-by: Vítor Zeni <vitor.zeni@bairesdev.com>
vsz-work
force-pushed
the
lp2174604-pro-contract-url
branch
from
November 18, 2026 13:00
8c64c2b to
137167c
Compare
vsz-work
force-pushed
the
lp2174604-pro-contract-url
branch
2 times, most recently
from
November 18, 2026 15:15
0253cf0 to
0766feb
Compare
…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>
vsz-work
force-pushed
the
lp2174604-pro-contract-url
branch
from
November 19, 2026 11:34
0766feb to
63bfa2b
Compare
gboutry
approved these changes
Nov 19, 2026
ahmad-can
approved these changes
Nov 20, 2026
This was referenced Nov 23, 2026
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.
The Ubuntu Pro contract server URL can't be set through Sunbeam (LP#2174604). The
deploy-proplan only passestokento the charm, socontract_urlalways keeps the charm default,https://contracts.canonical.com. The only workaround is a manualjuju config ubuntu-pro contract_url=…. Sunbeam doesn't own that value, so it isn't in the manifest and can be lost on a later apply or redeploy.Fixing that takes more than adding
contract_url. This PR has two commits:feat(pro): set the ubuntu-pro charm channel, revision and config from the manifestchannel,revisionand any charm option underfeatures.pro.software.charms.ubuntu-profix(pro): store the manifest passed to sunbeam enable --manifest <file> proenable --manifestnow saves the file in clusterdenable proruns. This also changes what--manifestdoes for pro (see below)1. Manifest passthrough for the
ubuntu-procharmfeature.py:default_software_overrides()registers theubuntu-procharm withchannel: UBUNTU_PRO_CHANNEL. Without this, manifest validation (SoftwareConfig.validate_charm_keys) rejects anyubuntu-proentry.manifest_attributes_tfvar_map()maps the charm'schannel,revisionandconfigto plan variables. This is the same pattern as images-sync and telemetry.main.tf/variables.tf:ubuntu-pro-revision(number, defaultnull) andubuntu-pro-config(map(string), default{}).ubuntu-pro-channelalready existed.revision = var.ubuntu-pro-revision.config = merge(var.ubuntu-pro-config, { token = var.token }). The token fromsunbeam enable pro <token>comes last, so it always wins over atokenkey in the manifest. In Python, the manifest and the CLI write different tfvars, so the "manifest > override" precedence never applies to the token.Example:
What this means beyond
contract_url:contract_url. See Other charm options below.latest/stable, now passed viaUBUNTU_PRO_CHANNEL). A userubuntu-proentry replaces the default entry as a whole, so with nochannelthe plan falls back to thevariables.tfdefault, which is the same value. A unit test checks that the two stay in sync.sunbeam manifest generatenow lists the pro charm under the feature's software.sunbeam cluster refreshnow uses the manifest's pro channel and revision.LatestInChannel(steps/upgrades/intra_channel.py:270) already runsjuju refreshon every app in the machines model,ubuntu-proincluded. It looks each charm up withmanifest.find_charm(), which also searches feature sections:ubuntu-proto the latest revision of its current channel (log:Running refresh for app ubuntu-pro (no manifest entry)).channelandrevision(log:... with manifest config), sosunbeam cluster refresh --manifest <file>can move the charm to another channel or pin a revision. With no user entry, the default entry giveslatest/stable, the channel it's deployed with, so the default behaviour is the same.juju refresh, not the deploy-pro plan, so it doesn't need the token, and the machine stays attached throughupgrade-charm(QA T10b). Refresh doesn't apply charm config such ascontract_url; that still needssunbeam enable pro <token>.enable prosends the same channel and revision. The Terraform apply then reports no changes, and the app isn't replaced (QA T10c).2.
enable --manifest <file> prostores the manifestrun_enable_plansstarts withAddManifestStepwhen--manifestis given, as the OpenStack features (features/interface/v1/openstack.py:202) and telemetry already do. Without--manifest, the plan is unchanged.Why it's needed: pro never stored a manifest. The file applied to that one run only. A later
sunbeam enable pro <token>read the clusterd manifest, fell back to an empty charm config and droppedcontract_urlagain.Behaviour change to be aware of:
AddManifestStepstores the file as the whole latest manifest, as for the other features. Before,--manifestwith pro was a one-off. Now it replaces the stored manifest, so pass a full manifest (e.g. fromsunbeam manifest show latest) with the pro section added, not a pro-only file.Not changed
sunbeam cluster refreshdoesn't run the deploy-pro plan. It can't, because the plan needs the token, which isn't stored. Running it with an empty token would detach every machine. So refresh changes the charm's channel and revision (see above) but not its config. To change a config value, re-runsunbeam enable --manifest <file> pro <token>, or runsunbeam cluster refresh --manifest <file>and thensunbeam enable pro <token>.Other charm options this enables
The passthrough isn't limited to
contract_url. Every option of theubuntu-procharm can now be set from the manifest. These are the options on the build Sunbeam deploys (latest/stable, rev 45,ubuntu@24.04); all are strings, which matches the plan'smap(string)variable.contract_urlhttps://contracts.canonical.com. Use it for an on-prem or proxied contract server (this bug).servicesesm-infra,livepatch. It replaces the default set. Useful to leave out services a cloud doesn't want, or to add ones that aren't on by default.livepatch_server_url+livepatch_tokenlivepatch.canonical.com.security_urlvulnerability_data_url_prefixapt_news_urloverride-http-proxy/override-https-proxyppaubuntu-advantage-toolsfrom a PPA instead of the archive, e.g. to test a client fix.override-ssl-cert-fileTogether,
contract_url,livepatch_server_url/livepatch_token,security_urlandvulnerability_data_url_prefixare what an air-gapped or on-prem Pro setup needs, so this covers more than the one URL in the bug.Caveats:
tokenin the manifest config is ignored: the CLI token always wins (see above).livepatch_tokenis a credential. Like everything in the manifest, it's stored in clusterd as plain text, unlike the Pro token, which is passed on the command line and never stored. Worth a line in the docs.contract_url. Withhttps://contracts.canonical.com:443, every Pro client request gets503 Service Unavailable. The client sendsHost: contracts.canonical.com:443over HTTP/1.1, and Canonical's front-end doesn't route that host (curl --http1.1with that header reproduces it). Seen in QA; worth a line in the docs.ubuntu-advantagecharm on the stable branches has the same options exceptapt_news_url,security_urlandvulnerability_data_url_prefix.sunbeam enable prothen fails with the Terraform error, e.g.parsing settings for application: unknown option "contrct_url"(tested in QA).Closes-Bug: #2174604
QA steps
Unit tests:
New tests in
test_pro.py:TestManifestCharmConfig(commit 1) checks that:ubuntu-prowithUBUNTU_PRO_CHANNELvariables.tffeatures.pro.software.charms.ubuntu-propasses validation and producesubuntu-pro-configandubuntu-pro-revisiontfvarsTestRunEnablePlans(commit 2) checks that--manifestputsAddManifestStepfirst in the enable plan, and that it's absent without--manifest.On a single-node deployment, with a snap built from this branch and a Pro token (the full QA runbook has T1–T9):
With a contract URL that isn't reachable, the unit goes Blocked and
enable proreports the attach error.Tested
ruff format,ruff checkandmypy sunbeamare clean.test_pro.pypasses on the first commit alone. The newTestRunEnablePlanstest fails without theAddManifestStepchangeterraform fmt -checkandterraform validateondeploy-promerge()precedence (terraform console)merge({contract_url=…, token="from-manifest"}, {token="from-cli"})givestoken = "from-cli"contract_urlis the charm default; noubuntu-pro-configtfvarcontract_urlin--manifestjuju configand/etc/ubuntu-advantage/uaclient.conf; the machine attached--manifestkeeps the value--manifestis reusedtokenkey in the manifest configcontract_urlenable profails withFailed to attach machine. See https://ubuntu.com/pro/dashboardcontract_urlgoes back to the charm default; the Juju provider resets removed keysenable profails:unknown option "contrct_url"services: esm-infraon a fresh attachesm-infraenabledubuntu-proand itsjuju-inforelation removedcluster refresh --manifest, channellatest/stable→latest/edgelatest/stablerev 45 →latest/edgerev 45. Refresh loggedRunning refresh for app ubuntu-pro with manifest config. Same revision, so noupgrade-charm. Token is the CLI one; still attached, same servicescluster refresh --manifest, pinnedrevision: 44latest/edgerev 44.upgrade-charmthenconfig-changedran, with no detach or re-attach. Token kept; still attached; unit activeenable proafter the refreshubuntu-pro-channel: latest/edge,ubuntu-pro-revision: 44from the stored manifest.Apply complete! Resources: 0 added, 0 changed, 0 destroyed; charm unchanged; still attachedbase.yamlviaenable --manifestlatest/stablewith no revision.0 added, 1 changed, 0 destroyed(in place); charm back tolatest/stablerev 45; still attachedFor T10: on Charmhub,
latest/stableandlatest/edgeboth hold rev 45 forubuntu@24.04amd64 (checked 2026-11-19). Only the older bases differ (edge 50, stable 48). So the stable → edge switch changes the channel but not the revision. T10b pins rev 44, the previous 24.04 amd64 build, to test a real revision change, including a downgrade, which Juju accepted.Sunbeam VM runs (T1–T9 on 2026-11-17, T10 on 2026-11-19):
ubuntu-prolatest/stable.mainwithout it). fix(pro): detach machines from Ubuntu Pro before removing the charm #1028 isn't included, so after each disable the machine was detached by hand.https://contracts.canonical.com/. The Pro client joins paths withposixpath.joinafter stripping the leading/, so a trailing slash builds the same request URLs as the default while the config string still differs. A first try with:443failed; see the caveat above.T2, tfvars written by Sunbeam (token removed) and the charm's log:
{ "ubuntu-pro-config": { "contract_url": "https://contracts.canonical.com/" }, "machine_model_uuid": "…" }T8 after a fresh attach with
services: esm-infra:{ "attached": true, "services": ["esm-infra"] }Backport notes
This bug also targets 2024.1 and 2026.1. Both stable branches still deploy the
ubuntu-advantagecharm (#1020 is only on main), so the backports need separate, hand-adapted PRs:ubuntu-advantage.ubuntu-advantage-channel(existing),-revisionand-config.latest/edge, to match the stable plan's variable default. Using main'slatest/stablewould silently move existing users to a different channel.ubuntu-prokey.ubuntu-advantageentry would fail on a snap that only knowsubuntu-pro. This needs either an alias or rename on load, or an upgrade note. Open to opinions.Links
ubuntu-procharm)Jira card: OPEN-4937