-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Optimize patches returned by Defaulter #2800
Comments
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/lifecycle frozen |
Would't it be possible to solve this by constructing the Patch not with That would accurately capture the differences that the validator actually made, rather than potentially also including a bunch of unrelated stuff due to go type not perfectly matching with the configured CRD. |
I think this will lead to other problems. See the first two comments in this thread: #2931 (comment) Basically the patches then won't be generated based on the actual JSON anymore, so then there are cases where the apiserver won't be able to apply the JSON patches. |
@sbueringer @alvaroaleman I've opened #2982 , in it, the approach is similar to the one in #2931, but we only make sure that the removals that are generated by the object decoding are not part of the final patch. Additionally, we can make this behavior optional and maybe add some warnings in result indicating which fields wold have bean removed by the decoding itself. |
Today our Defaulter and CustomDefaulter implementations always compare the entire
req.Object.Raw
with the object mutated by theDefault
func.The result is that we always return patches for metadata, spec and status if there are differences including cases where e.g. the status marhals to an empty object. For example in the latter case the webhook returns a patch to add an empty status object.
We have the following cases where the Defaulter webhook is called:
WithDefaulter
func.req.SubResource == "status"
The reason why I'm bringing this up is because I've noticed that in a lot of cases our Cluster API webhooks are returning patches for status fields that are never used (and eventually discarded by the apiserver). Would be better if we don't return those patches in the first place. If we only compare the relevant parts of the object we should be also able to slightly improve the performance of the webhooks.
The text was updated successfully, but these errors were encountered: