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

Runtime error due to nil pointer dereference on TargetRef fields missing #646

Closed
ppatierno opened this issue Mar 1, 2020 · 5 comments · Fixed by #648
Closed

Runtime error due to nil pointer dereference on TargetRef fields missing #646

ppatierno opened this issue Mar 1, 2020 · 5 comments · Fixed by #648
Assignees
Labels
bug Something isn't working

Comments

@ppatierno
Copy link
Contributor

When a ScaledObject resource is created but it's missing both the scaledTargetRef and the jobTargetRef fields, the controller assumes its ScaleType is a "job" but then a runtime error happens due to a nil pointer dereference.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1ef8f0a]

goroutine 468 [running]:
github.com/kedacore/keda/pkg/handler.(*ScaleHandler).resolveJobEnv(0xc0008ce660, 0xc000347ba0, 0x0, 0x0, 0x0)
	/home/ppatiern/github/keda/pkg/handler/scale_jobs.go:99 +0x5a
github.com/kedacore/keda/pkg/handler.(*ScaleHandler).getJobScalers(0xc0008ce660, 0xc000347ba0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/ppatiern/github/keda/pkg/handler/scale_handler.go:224 +0xaf
github.com/kedacore/keda/pkg/handler.(*ScaleHandler).handleScaleJob(0xc0008ce660, 0x2d88a40, 0xc00059f700, 0xc000347ba0)
	/home/ppatiern/github/keda/pkg/handler/scale_loop.go:53 +0xe5
github.com/kedacore/keda/pkg/handler.(*ScaleHandler).handleScale(0xc0008ce660, 0x2d88a40, 0xc00059f700, 0xc000347ba0)
	/home/ppatiern/github/keda/pkg/handler/scale_loop.go:42 +0xbe
github.com/kedacore/keda/pkg/handler.(*ScaleHandler).HandleScaleLoop(0xc0008ce660, 0x2d88a40, 0xc00059f700, 0xc000347ba0)
	/home/ppatiern/github/keda/pkg/handler/scale_loop.go:14 +0x317
created by github.com/kedacore/keda/pkg/controller/scaledobject.(*ReconcileScaledObject).startScaleLoop

/home/ppatiern/github/keda/pkg/controller/scaledobject/scaledobject_controller.go:318 +0x5d3

It happens in the resolveJobEnv method.
I would fix it just doing a check in the caller method getJobScalers that the jobTargetRef is not nil and returning an error eventually. Maybe we should do the same in the GetDeploymentScalers even if it should not happen.

@ppatierno ppatierno added the bug Something isn't working label Mar 1, 2020
@tomkerkhove
Copy link
Member

Sounds good to me, thanks

@ppatierno
Copy link
Contributor Author

@tomkerkhove if you want, you can assign this to me.

@zroubalik
Copy link
Member

@ppatierno thanks, I've just found the problem as well. Working on the fix already, so I can handle this, in case you haven't already started :)

@ppatierno
Copy link
Contributor Author

@zroubalik not yet started, I can do it this evening but if you can work on it right now, I am fine to give the issue to you ;-) your call!

@zroubalik
Copy link
Member

@ppatierno ok, I'll assign to myself, you deserve some rest :) thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants