-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
✨ clusterctl alpha topology-dryrun #5893
✨ clusterctl alpha topology-dryrun #5893
Conversation
|
21028c8
to
88ec975
Compare
88ec975
to
8f49f8f
Compare
/retest |
/test pull-cluster-api-verify-main |
/retest |
8f49f8f
to
27cc281
Compare
|
/retest |
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.
This is great work!
first pass, mostly nits
@fabriziopandini thank you for the review. |
I'll take a closer look on Monday. |
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.
First round of review
Do create/update requests go through validation webhooks? That is, are they sent to a Kubernetes API? It looks like If they do not, then I think it's worth making this explicitly a "client-side" dry-run, e.g., > kubectl create --help | grep dry
--dry-run='none': Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource. |
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.
@dlipovetsky Within this dry run code we run validation and defaulting but only for Cluster and ClusterClass types. We do this not by running them through the webhooks, instead we run the validation and defaulting functions directly.
Defaulting and Validation of any of the provider types is out of scope for this feature.
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.
There are a few more comments I need to address.
Resolving some conversations and replying to some comments in the mean time.
d63aec5
to
e2d4237
Compare
FYI: The new size of the clusterctl binary on linux amd64 is ~60mb. Previously it was ~52mb. |
cmd/clusterctl/client/cluster/assets/topology-test/existing-clusterclass-and-cluster.yaml
Outdated
Show resolved
Hide resolved
object := o.DeepCopyObject().(client.Object) | ||
if err := localScheme.Convert(obj, object, nil); err != nil { | ||
return errors.Wrapf(err, "failed to convert object to %s", obj.GetKind()) | ||
} |
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.
Q: why wo we have to do this. Couldn't we just use the obj
directly?
If I'm right we might also don't need the back-conversion at the end of the loop
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 cant use obj
directly. The defaulter and validator expect types like Cluster
and ClusterClass
and that is object
. Hence we use convert to basically move data from unstructured to object
(typed object) and then move back to unstructured.
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.
First part of the review - just a lot of nits 😄
e2d4237
to
789b804
Compare
789b804
to
ecf198e
Compare
Great work!! /lgtm |
/lgtm Code looks good! I'm going to spend some time playtesting but if anything comes up I can create an issue and we can patch. |
ecf198e
to
dcc22db
Compare
@ykakarap: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/lgtm |
This is a super powerful feature! |
Overall this feature looks great, my only comment is about the UX for the command itself, consider to have something like clusterctl alpha topology plan [...] We can always follow-up for this, not a blocker for this PR, but release blocking |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabriziopandini The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
This PR implements a alpha new command:
clusterctl alpha topology-dryrun
.This command can be used to dry run ClusterClass and/or Cluster changes.
The command expects as input a file that includes the new or modified objects. Example: the file can contain a modified Cluster or a modified ClusterClass. The output lists all the Clusters and ClusterClasses that will be affected.
The following example shows the output when dry-running to create a Cluster that uses a pre-installed ClusterClass.
Special thanks to @fabriziopandini for providing guidance for this feature. 🙂
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #5319