-
Notifications
You must be signed in to change notification settings - Fork 718
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 webhook phase 1 #2072
Add webhook phase 1 #2072
Conversation
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
} | ||
|
||
func (r *Elasticsearch) ValidateUpdate(old runtime.Object) error { | ||
eslog.Info("validate update", "name", r.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.
should it be debug level?
return errors.New("cannot cast old object to Elasticsearch type") | ||
} | ||
var errs field.ErrorList | ||
|
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.
nit: move the variable declaration one line below?
duplicateNodeSets = "NodeSet names must be unique" | ||
noDowngradesMsg = "Downgrades are not supported" | ||
unsupportedVersionMsg = "Unsupported version" | ||
unsupportedUpgradeMsg = "Unsupported version upgrade path" |
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.
Should we use capitalize the first word of them all for consistency?
Partially fixes #1769
Fixes #2068
This is just the first phase for re-adding the webhook validation for kubebuilder v2. In kubebuilder v2, webhooks are implemented with a receiver of the custom resource type. You can see the docs here. This leaves us in more or less the same position we were in before, but in a position to implement the webhook. I wanted to merge this sooner than later as it touches a lot of files. The changes in the future should mostly just be in the webhook handling code.
Unfortunately we had validation code in a few dependent packages, so this required a bit of refactoring to avoid circular dependencies. Including:
VerifySupportsExistingPods
was also moved to the driver since that was the only caller and it seemed to make more sense thereUpstream validation funcs also returns
field.ErrorList
s, which are nice because it provides an easy way to point out exactly which part of the path is wrong and what the invalid value is. It meant a little rework in our validation funcs, but it seems easier to read imo.specUpdatedToBeta()
and that the count of any node set is positive.Still to do
I had two things I was not sure about:
Do we want to actually generate the webhook yaml right now? It doesn't do anything right now, but it is necessary for the next phase
Do we want to double check that the nodeSet len is positive and that the nodeSet counts are positive in the validation funcs? In general I don't think we need to re-implement OpenAPI, but since we do not have OpenAPI validation right now I can see the argument for it. But hopefully we do by the time we cut a new release