-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add metalctl
command line interface
#162
Conversation
Thanks @SzymonSAP. Can you open the PR directly against the |
c0f7ff0
to
441f587
Compare
Sure, done it. Please let me know if the changes are on the right track and share any ideas what edge cases should also be covered. |
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.
Thanks, for looking into this. 👍 Besides some small stuff, I think to larger topics are missing.
Firstly, the status
of custom resources need to be copied over. This is especially important for Servers
, where the status contains the lifecycle phase. Not copying the status here, would re-provision running servers (due to the reset into the discovery phase). One needs to use cl.Status().Update()
to set the status after creation of a resource.
Secondly, the metal-operator uses owner references on many resources. They cannot be moved directly as they contain the UID of the owner, which is assigned on creation at random. To move these the owner needs to be looked up in the target cluster by name to patch the UID. E.g.
var endpoint metalv1alphav1.Endpoint
if err := clients.target.Get(ctx, types.NamespacedName{Name: owner.Name}, &endpoint); err != nil {
return err
}
cr.OwnerReferences[0].UID = endpoint.UID
As a side effect this requires ordering the creation of CRs properly. E.g. Endpoints
need to be handled first, then BMC
and BMCSecrets
and so on. In that regard it may be worth thinking about an "integration" test, which creates an Endpoint
against the redfish simulator in source cluster with the metal-operator attached and then try moving.
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.
Thanks for implementing the handling of owner references. The implementation seems fine on a quick glance. 👍 I've added a few comments on stuff I'm unsure about.
43b8a6a
to
90166fe
Compare
Can you please rebase this PR branch and use #179 to add the license headers to all net-new go files? |
I have pushed requested changes and rebased the PR. Please have a look ;) |
I had a short alignment with @afritzler today. Here are the 2 main outcomes:
|
cmd/metalctl/app/move.go
Outdated
if err = cl.Create(ctx, crsTree.Cr); err != nil { | ||
err = fmt.Errorf("CR %s couldn't be created in the target cluster: %w", crName(crsTree.Cr), err) | ||
return | ||
} |
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 think the status subresource creation is missing.
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 have added status update after getting CR however in tests cl.Create
creates object with status so I'm not sure if it will work on real environment. It would be good to test using clusters.
Also it would make sense to add new documentation section |
cmdutils/suite_test.go
Outdated
var mgrCtx context.Context | ||
mgrCtx, cancel := context.WithCancel(context.Background()) | ||
DeferCleanup(cancel) | ||
registryServer := registry.NewServer("localhost:30000") |
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 would leave out the registry server out of this test suite.
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.
done ;)
@SzymonSAP can you add above this line https://github.com/ironcore-dev/metal-operator/blob/main/internal/controller/bmc_controller_test.go#L14
And describe in the |
I added documentation strongly inspired by https://cluster-api.sigs.k8s.io/clusterctl/commands/move.html |
Proposed Changes
This PR adds
metaclt move
command with it's flags described in a issue #146.To discuss
done
done
Fixes #146