fix: model migration from 3.6 to 4 with an LXD virtual machine#21651
Merged
fix: model migration from 3.6 to 4 with an LXD virtual machine#21651
Conversation
gfouillet
approved these changes
Jan 27, 2026
Contributor
gfouillet
left a comment
There was a problem hiding this comment.
Looks good, thank you.
| // The ProviderSubnetID is not required. The contrived values for LXD | ||
| // serve no purpose, remove them from the model data from 3.6. | ||
| var providerSubnetID string | ||
| if cloudType != "lxd" { |
Member
There was a problem hiding this comment.
This should be a constant somewhere.
Member
Author
There was a problem hiding this comment.
There is not a generic constance for any of the provider types, not sure why. Even the register provider code uses strings.
Interestingly there is a set of K8SCloud* types, e.g. K8sCloudLXD.
Unfortunately the types in the cloud domain, are for the cloud_type id as integers. The String method converts with strings.
I completely clouds need type strings. However it should be done as a small project across the board and is outside of the scope of this PR.
3d9ddcb to
fe4a63c
Compare
SimonRichardson
approved these changes
Jan 27, 2026
fe4a63c to
411bfb4
Compare
The provider subnet id is contrived and can contain incorrect data depending on which lxd container type is in use. Nor it is required by juju. Stop creating it. Same with provider id. With provider subnet ids, remove the prefix of nic-, it is superfluous.
When importing link layer devices, do not use the subnet provide id as the data by be incorrect from 3.6, preventing migration. When importing subnets, do not save the provider id. It's contrived and not real. Remove the prefix net- from provider network ids. Again, it is contrived and not required.
The provider network id is not required, do not attempt to add rows for empty string ids.
For lxd models, remove the subnet provider id and remove the net- prefix from network provider ids. Neither value is required by juju. For lxd they are contrived and sometimes inconsistent causing failures where at attempt to match is made.
97df093 to
3a6b228
Compare
Member
Author
|
/merge |
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.
Fixes model migration from 3.6 to 4 where the model contains LXD virtual-machines. Link layer device import fails with:
machine-0: 20:42:46 INFO juju.worker.migrationmaster.3af583 logger-tags:migration aborted, removing model from target controller: model data transfer failed, failed to import model into target controller: execute operation import link layer devices: importing link layer devices: converting device "enp5s0" on machine "0": converting address "10.74.147.39/24": no subnet found for provider subnet ID "subnet--10.74.147.0/24"The subnet does exist assubnet-lxdbr0-10.74.147.0/24.3.6 contrives the provider subnet id and the network name was not available in all code paths. Thus the subnet saves the provider id as
subnet-lxdbr0-10.74.147.0/24. However it was created assubnet--10.74.147.0/24. With lxd virtual machines, 3.6 allows the name of link layer devices toenp5s0rather thaneth0and cannot match the lxd api returned data correctly between the two different names.NOTE: model migration with an lxd virtual machine still fails if the k8s charm is deployed, the error has moved:
'migrating: aborted, removing model from target controller: model data transfer failed, failed to import model into target controller: execute operation import link layer devices: importing link layer devices: converting device "cilium_host" on machine "0": converting address "10.1.0.40/32": no subnet found'. In 3.6 this ip address is saved without a corresponding subnet.The fix is in 3 parts: new deployments, model migration and controller upgrade with the same results. Provider subnet ids do not exist for lxd cloud models, and the prefix of
net-is removed from the provider ids of networks. Neither bits of data is required and in the case of lxd, contrived and not provided by the provider.Removing the provider subnet id uncovered one place where it was expected:
addProviderLinkLayerDevice, part ofMergeLinkLayerDevice. More investigation is warranted to ensure this is done correctly. JUJU-9106TODO: Investigate why the subnet CIDR is set as the subnet's provider id on new 4.0.2 models.
TODO: Resolve issue with
cilium_hostaddress on virtual machines with k8s charm failing to migrate. JUJU-9101Checklist
Integration tests, with comments saying what you're testingdoc.go added or updated in changed packagesQA steps
Links
Jira card: JUJU-9068