kubernetes-sigs / controller-runtime

Repo for the controller-runtime subproject of kubebuilder (sig-apimachinery)
Apache License 2.0
2.56k stars 1.15k forks source link

The custom mutation handler failed to process the deletion request of CR #2048

Closed iiiceoo closed 1 year ago

iiiceoo commented 1 year ago

Version

Reproduce

  1. Enable CRD deletion mutation in MutatingWebhookConfiguration.
  2. Execute kubectl delete <CRD> <CR>, and get error message "there is no content to decode".

Reference

1762

1765

iiiceoo commented 1 year ago

I encountered the same problem as in #1762. When I delete the CR, the error "there is no content to decode" is returned from the mutating webhook.

The only difference is that I registered webhook for CR in the following way:

return ctrl.NewWebhookManagedBy(sm.runtimeMgr).
    For(&xxx.CR{}).
    WithDefaulter(sm).
    WithValidator(sm).
    Complete()

Then I found that the bug was only solved in the handler of interface Defaulter, but not in interface CustomDefaulter.