kubernetes-sigs / controller-runtime

Repo for the controller-runtime subproject of kubebuilder (sig-apimachinery)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

admission.Decoder.Decode is panicking after version bump

mahmud2011 opened this issue · comments

I updated controller-runtime from v0.14.4 to v0.15.3 along with k8s.io/* from v0.26.2 to v0.27.7.

type PodMut struct {
    decoder        *admission.Decoder
    ...
}


func (pm *PodMut) Handle(ctx context.Context, req admission.Request) admission.Response {
	pod := &corev1.Pod{}
	err := pm.decoder.Decode(req, pod)
        ...
}
runtime error: invalid memory address or nil pointer dereference

/usr/local/go/src/runtime/panic.go:920 +0x270
sigs.k8s.io/controller-runtime/pkg/webhook/admission.(*Decoder).DecodeRaw(0x0, {{0xc000018b00, 0x2049, 0x2529}, {0x0, 0x0}}, {0x1a42b72, 0xc000229690})

I don't see any breaking changes for this in release log. I also inspected the dump using spew couldn't figure out why it's panicking.

/kind support

https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.15.0 shows that

Add constructors for webhook/conversion, remove webhook/admission.GetDecoder() (https://github.com/kubernetes-sigs/controller-runtime/pull/2144)
There are two set of changes related to the webhooks and how they're exposed. For users using the Manager, there should be minimal to no required changes.
webhook/admission/Webhook.GetDecoder() method has been removed, it was unused before and relied on runtime dependency injection.
webhook/conversion.Webhook struct has been un-exported. Users should use webhook/conversion.NewWebhookHandler instead.
pkg/webhook/admission:
Use Result.Message instead of Result.Reason (https://github.com/kubernetes-sigs/controller-runtime/pull/1539)
Validator and CustomValidator interfaces have been modified to allow returning warnings (https://github.com/kubernetes-sigs/controller-runtime/pull/2014)

Not sure if you are running into issues with this or something involved with the admission.NewDecoder. Can you provide a little more clarity with more information beyond the snippet?

@mahmud2011 Please provide more of the stacktrace (at least from: pm.decoder.Decode(req, pod)). You can censor file paths if necessary