Repository navigation
fix(pro): pass machine_model_uuid when disabling Ubuntu Pro - #1023
Merged
Merged
Conversation
vsz-work
force-pushed
the
open-4916-fix-pro-disable
branch
from
November 10, 2026 13:38
c028f72 to
f6bb530
Compare
vsz-work
force-pushed
the
open-4916-fix-pro-disable
branch
2 times, most recently
from
November 10, 2026 18:27
48f5b9b to
38c4fe1
Compare
hmlanigan
reviewed
Nov 10, 2026
hmlanigan
left a comment
There was a problem hiding this comment.
looks good, but i have a question on whether this is the correct approach and follows the patterns set out by different features.
Raven-182
previously approved these changes
Nov 10, 2026
Raven-182
left a comment
There was a problem hiding this comment.
Thanks, LGTM, the change makes sense given your explanation in the comments
|
I'll approve once the merge conflicts are resolved. |
ahmad-can
requested changes
Nov 13, 2026
vsz-work
force-pushed
the
open-4916-fix-pro-disable
branch
from
November 13, 2026 11:14
38c4fe1 to
c30b437
Compare
hmlanigan
previously approved these changes
Nov 19, 2026
Raven-182
previously approved these changes
Nov 19, 2026
ahmad-can
previously approved these changes
Nov 20, 2026
|
@vsz-work please resolve the merge conflicts |
Collaborator
|
Can you mark the comments as resolved if they are please? @vsz-work |
vsz-work
force-pushed
the
open-4916-fix-pro-disable
branch
from
November 23, 2026 12:07
c30b437 to
c753f0f
Compare
Author
gboutry
approved these changes
Nov 23, 2026
vsz-work
force-pushed
the
open-4916-fix-pro-disable
branch
from
November 23, 2026 13:33
c753f0f to
47f23b5
Compare
`sunbeam disable pro` always failed with: No value for required variable: The root module input variable "machine_model_uuid" is not set, and has no default value. The pro plan does not persist its tfvars (tfvar_config=None), so update_tfvars writes only the override_tfvars of the current run. The disable step passed only the emptied token, leaving the required machine_model_uuid unset and terraform refusing to plan. The application was never removed. Resolve the machine model UUID in the disable step, the same way the enable step does, and pass it alongside the empty token. In both steps, look the model UUID up inside the try block, so a missing model or a Juju error fails the step instead of escaping as an unhandled exception. Also catch TerraformStateLockedException in the disable step, as the enable step does: it is not a TerraformException, so a locked state showed a traceback instead of failing the step. Update test_disable, which asserted the broken tfvars, and add regression tests checking that both the enable and disable steps pass every deploy-pro variable that has no default, and that both fail cleanly when the model lookup fails. Jira: OPEN-4916 Assisted-By: Claude Code (Claude Opus 5.5) Related-Bug: #2158218 Signed-off-by: Vítor Zeni <vitor.zeni@bairesdev.com>
vsz-work
force-pushed
the
open-4916-fix-pro-disable
branch
from
November 23, 2026 20:08
47f23b5 to
51a2c8b
Compare
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.
sunbeam disable proalways fails, and the Ubuntu Pro application is never removed:The pro plan doesn't save its Terraform variables between runs (
tfvar_config=None), soupdate_tfvarswritesterraform.tfvars.jsonfrom the current run'soverride_tfvarsonly. The enable step passesmachine_model_uuidandtoken, but the disable step passed only the empty token. That leftmachine_model_uuid, whichdeploy-pro/variables.tfrequires with no default, unset, so Terraform refused to run.This PR makes the disable step look up the machine model UUID the same way the enable step does, and pass it along with the empty token.
run_disable_plansnow passes the Juju helper and the machine model toDisableUbuntuProApplicationStep.Both the enable and disable steps now look up the model UUID inside their
tryblock. A missing model (ModelNotFoundException) or anotherJujuExceptionfails the step with its message, instead of escaping as an unhandled exception.The disable step now also catches
TerraformStateLockedException, as the enable step already did. It isn't a subclass ofTerraformException, so a locked Terraform state during disable showed a traceback instead of failing the step.Tests:
test_disableasserted the broken variables ({"token": ""}); it now expectsmachine_model_uuidas well.TestRequiredTerraformVariablesreadsdeploy-pro/variables.tfand checks that both the enable and disable steps pass every variable without a default, so a future required variable can't break disable the same way. Its regex only handles flat variable blocks, asdeploy-prohas today; the helper's docstring notes this.test_enable_model_lookup_failedandtest_disable_model_lookup_failedcheck that each step returns FAILED, without running Terraform, when the model lookup raisesModelNotFoundExceptionorJujuException.test_disable_tf_apply_failednow also coversTerraformStateLockedException.The same pro code is on
stable/2025.1andstable/2026.1, sodisable prois broken there too.This fix is needed for the ubuntu-advantage → ubuntu-pro charm switch (OPEN-4793). The only supported migration path is
sunbeam disable profollowed bysunbeam enable pro, which can't work while disable fails.Related-bug: #2158218
QA steps
Automated:
cd sunbeam-python tox -e pep8,mypy tox -e unit -- tests/unit/sunbeam/features/test_pro.pyReproduce on the current snap (needs an Ubuntu Pro token):
2026.1/edgesnap and runsunbeam enable pro <token>.sunbeam disable pro.2026.1/edge(rev 1165) it fails with an empty error:Error: terraform command failed: .../terraform apply ... -jsonfollowed by a blankstderr:. Sunbeam runs Terraform with-json, which writes the error to stdout, andstable/2026.1prints only stderr.main, where 5d3e0fc extracts the error from the JSON output, it fails withNo value for required variable ... "machine_model_uuid".terraform.tfvars.jsonin theubuntu-pro-planworking folder contains only{"token": ""}.juju status -m openstack-machines ubuntu-prostill shows the application.Verify the fix:
sudo snap install --dangerous <snap>, then reconnect the interfaces as indocs/CONTRIBUTING.md.sunbeam disable pro.ubuntu-proapplication and itsjuju-infointegration withsunbeam-machineare removed.juju status -m openstack-machines --format json | jq '.applications | has("ubuntu-pro")'returnsfalse.sunbeam enable pro <token>.Tested
On 2026-11-10, a single-node 2026.1 cluster in an LXD VM, with pro enabled on the
2026.1/edgesnap (charmubuntu-advantage):sunbeam disable pro2026.1/edgerev 1165stderr:main+ the ubuntu-pro charm switch, without this fixNo value for required variable ... "machine_model_uuid"juju-infointegration are removed.ubuntu-prowas already gone when the command returned, so the Terraform Juju provider waits for the removal and no extra wait is neededA following
sunbeam enable prowith the fixed build deployed the newubuntu-procharm and attached the machine.Known gap, not changed here: disable doesn't detach the machine.
sudo pro statusstill shows it attached after disable. The charm has no remove or stop handler and only runspro detachwhen itstokenconfig is set to empty. This plan deletes the application instead (count = 0), so machines stay attached and keep using a seat. The fix, a detach step that empties the token and waits for every unit before Terraform removes the application, is in a follow-up PR stacked on this one: #1028.Logs for
sunbeam disable pro:disable.log
Links
Jira card: OPEN-4916