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.
Sounds good to me, thanks
@tomkerkhove if you want, you can assign this to me.
@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 :)
@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!
@ppatierno ok, I'll assign to myself, you deserve some rest :) thanks!
Most helpful comment
@ppatierno ok, I'll assign to myself, you deserve some rest :) thanks!