-
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
✨ Make Clusterclass webhook Cluster-aware #5717
✨ Make Clusterclass webhook Cluster-aware #5717
Conversation
f88ff15
to
ca2b241
Compare
6230e28
to
f2fc925
Compare
Please let me know when I should do another review and please resolve the straightforward findings (i.e. the conversations) which have been fixed. |
8e228de
to
3692624
Compare
3692624
to
dc5bb91
Compare
internal/webhooks/clusterclass.go
Outdated
} | ||
|
||
// Retrieve all clusters using the ClusterClass. | ||
clusters, err := webhook.getClustersUsingClusterClass(old) |
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.
In this case we will now have an apierror wrapped into an field error wrapped into an apierror. I'm not sure what the error for users will look like.
My intention was to suggest the following:
- return a regular error in
getClustersUsingClusterClass
- ValidateDelete:
- Take the error and wrap it into an apierror in
ValidateDelete
- Take the error and wrap it into an apierror in
- ValidateCreate/Update
- Call
getClustersUsingClusterClass
directly invalidate
instead of invalidateRemovedMachineDeploymentClassesAreNotUsed
, if there is an error wrap it into an apierror and return it- If I understood it correctly we have to move
getClustersUsingClusterClass
that level up anyway sooner or later to avoid calling this func multiple times.
- If I understood it correctly we have to move
- Call
WDYT?
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 we're going to have to wrap the client error into a field.ErrorList at that level anyway in order to retain the errors from earlier in validate. I'll update with what I have, but I don't see any direct and clean way to wrap all of these errors into something that will be perfect in every case.
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'm not sure but when getClustersUsingClusterClass
is called directly in validate
I would have thought that we can just return the error we want, but maybe I'm missing something
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.
Validate will already have some errors wrapped in field.ErrorList by the time getClustersUsingClusterClass is called so we should wrap that error in the same way.
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.
As discussed, we now have one api error which contains a list of field errors and that's fine (as we still want to return the field errors)
97e1a69
to
350f5ec
Compare
/retest |
350f5ec
to
794e1a6
Compare
Signed-off-by: killianmuldoon <[email protected]>
794e1a6
to
ac639c2
Compare
/lgtm |
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.
/lgtm
/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 |
Add cluster aware checks to the clusterClass webhook that:
Previously:
Note this is built on top of #5318 and should not be merged until after that PR is merged. Changes introduced in this PR are in the second commit.
Fixes: #5498