New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JUJU-390] Transfer machine DisplayName through migration #13645
Conversation
provider/oci/environ.go
Outdated
@@ -322,7 +322,7 @@ func (e *Environ) Create(ctx envcontext.ProviderCallContext, params environs.Cre | |||
|
|||
// AdoptResources implements environs.Environ. | |||
func (e *Environ) AdoptResources(ctx envcontext.ProviderCallContext, controllerUUID string, fromVersion version.Number) error { | |||
return errors.NotImplementedf("AdoptResources") | |||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we do not longer return NotImplemented? Even if this is not necessary for OCI, this is more useful than returning nil
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That NYI error is breaking migration on the OCI, and unrelated to this PR, and returning nil
is just a temporary patch to be able to run and test this PR. (I believe the people filed the bug were using maas). See LP #1958459. I might go tackle that afterwards too. But currently returning nil here is just temporary and again, will be reverted before landing.
go.mod
Outdated
@@ -144,6 +144,8 @@ require ( | |||
|
|||
replace github.com/altoros/gosigma => github.com/juju/gosigma v0.0.0-20200420012028-063911838a9e | |||
|
|||
replace github.com/juju/description/v3 => github.com/cderici/description/machine-display-name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be changed after juju/description is merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is to allow this PR to use another PR on my description
fork, which is a requirement of this PR and will be landed before, so I'll revert this back as well 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After running QA I'm OK with the changes.
Do not merge before passing tests and replacing go.mod reference to the original description repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing QA now.
Please add updated unit tests migration import and export.
state/migration_import.go
Outdated
@@ -577,6 +577,10 @@ func (i *importer) machineInstanceOp(mdoc *machineDoc, inst description.CloudIns | |||
if arch := inst.Architecture(); arch != "" { | |||
doc.Arch = &arch | |||
} | |||
if displayName := inst.DisplayName(); displayName != "" { | |||
doc.DisplayName = displayName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: since display name is not a pointer, nor is it labeled omit empty in state, you can just do
DisplayName: inst.DisplayName(),
above, in ln 571-574.
#13653 #### Description Migration fails on some providers (e.g. oci) because of some not yet implemented/optional features. This unblocks it by returning nil whenever it sees an nyi. All the other errors are raised as usual. Fixes: https://bugs.launchpad.net/juju/+bug/1958459 #### QA steps Migration on oci should succeed. (use the compartment&tenancy ids from within the cloud-city) ```sh juju bootstrap --config compartment-id=$OCID_COMPARTMENT oci-canonical oci-test-controller2 juju bootstrap --config compartment-id=$OCID_COMPARTMENT oci-canonical oci-test-controller1 juju add-model --config compartment-id=$OCID_COMPARTMENT test-model1 juju deploy ubuntu juju migrate test-model1 oci-test-controller2 ``` #### Notes & Discussion This is sort of a requirement for #13645, as we need the migration to be working for that to take effect.
93fa60e
to
7ae1a8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor change required.
state/machine.go
Outdated
@@ -279,6 +279,14 @@ func (m *Machine) HardwareCharacteristics() (*instance.HardwareCharacteristics, | |||
return hardwareCharacteristics(instData), nil | |||
} | |||
|
|||
func (m *Machine) DisplayName() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to add this exported method just for tests. Someone will end up using it in production code and we've got a double access for machine then instance data.
Instead, add a public method, GetInstanceData
to package_test.go that wraps the private method getInstanceData
and call that to get it directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok that makes sense, I'll make the change 👍 thanks for the review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized we already have a method called InstanceNames
in the machine package that I didn't know before, so I just used that one in the tests instead of redundantly adding a new method. Thanks for the catch!
includes temporary code that will be removed before the PR lands: - go.mod for external changed dependency (description pkg), and - provider/oci/environ.go for quick fix to allow the PR to run
To use the juju/description edge
DisplayName field is not a pointer, nor omitempty, so no need to check creating extra variables
Includes a helper function DisplayName() for state.Machine, normally not available since DisplayName is a field of instanceData (i.e. not Machine)
Using existing Machine.InstanceNames() method instead of exporting a new one
5edc7c4
to
25ad393
Compare
|
Description
This allows the machines (usually provided by OCI or MAAS) to be able to transfer their
DisplayName
fields through a migration.Fixes:
LP #1954969.
Requires:
QA Steps
You'll need either Oracle OCI or MAAS controllers for this one. (Other providers don't use display name)
I tested it with the OCI, like as follows (I used the compartment&tenancy ids from within the cloud-city):
Note the machine
Inst Id
in juju status, or dodb.instanceData.find().pretty()
in mongodb and look for thedisplay-name
field.Notes & Discussion
This PR also includes temporary code that will be removed before the PR lands: