You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today our Defaulter and CustomDefaulter implementations always compare the entire req.Object.Raw with the object mutated by the Default 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:
CRs without status subresource
for the entire object => we actually have to return patches for the entire object (correct as of today)
CRDs with status subresource
for spec & metadata => we should only return patches for spec & metadata (today we also return patches for status)
I'm not aware of any way to detect this at runtime, we could maybe introduce an option on the WithDefaulter func.
for status => we should only return patches for status (today we also return patches for spec & metadata)
We should be able to optimize this by dropping all non-status patches if 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:
k8s-ci-robot
added
lifecycle/frozen
Indicates that an issue or PR should not be auto-closed due to staleness.
and removed
lifecycle/stale
Denotes an issue or PR has remained open with no activity and has become stale.
labels
Jul 29, 2024
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: