Skip to content
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

Panic on nil pointer dereference #195

Closed
kirillmakhonin-brt opened this issue Sep 8, 2023 · 2 comments · Fixed by #200
Closed

Panic on nil pointer dereference #195

kirillmakhonin-brt opened this issue Sep 8, 2023 · 2 comments · Fixed by #200

Comments

@kirillmakhonin-brt
Copy link
Contributor

Hello
We've tried to use annotations proxy-pod-scheduling-constraints/use-constraints-from-spec-for-proxy-pod-scheduling on the latest version and 've recevied this error

2023/09/06 17:29:58 http: panic serving 10.64.18.99:57152: runtime error: invalid memory address or nil pointer dereference

goroutine 3623240 [running]:

net/http.(*conn).serve.func1()
  net/http/server.go:1802 +0xb9

panic({0x1818520, 0x2a70bf0})
  runtime/panic.go:1047 +0x266
admiralty.io/multicluster-scheduler/pkg/webhooks/proxypod.mutator.mutate({0xc00202d800}, 0xc000df4400)
  admiralty.io/multicluster-scheduler/pkg/webhooks/proxypod/proxypod.go:133 +0x48d

We suspect that issue is in the code that tries to access srcPod.Spec as Spec may be empty in corner cases

@adrienjt
Copy link
Contributor

Hi, Spec isn't a pointer, so that's no it. However, srcPod may be nil. I'll have a look.

@adrienjt
Copy link
Contributor

adrienjt commented Nov 4, 2023

I figured it out. This is because the webhook is reinvocated in your setup, since #193, so this code path is run:

if err := yaml.UnmarshalStrict([]byte(pod.Annotations[common.AnnotationKeySourcePodManifest]), srcPod); err != nil {

Deserialization should be done into an initialized object. Unfortunately, trying to deserialize into nil doesn't produce an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants