Closed nabokihms closed 1 year ago
Fixing a panic in runtime
Example of the panic message:
{"binding":"kubernetesSynchronization","binding.name":"values","event.type":"OperatorStartup","hook":"get_values.py","hook.type":"module","level":"info","module":"op-monitoring","msg":"ModuleHookRun task for Synchronization of 'main' group binding, trigger is OperatorStartup","queue":"monitoring","task.flow":"start","task.id":"2ed74914-7430-4921-aa8b-e5491d1eaa18","time":"2023-09-02T16:51:40Z"} panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2e955cb] goroutine 16835 [running]: github.com/flant/addon-operator/pkg/values/validation.ApplyDefaults({0x3972340?, 0xc0005bb0b0?}, 0xc005170480) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/values/validation/defaulting.go:55 +0x48b github.com/flant/addon-operator/pkg/values/validation.ApplyDefaults({0x3b63dc0?, 0xc000bec7b0?}, 0xc005170240) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/values/validation/defaulting.go:47 +0x445 github.com/flant/addon-operator/pkg/values/validation.ApplyDefaults({0x3b63dc0?, 0xc000bec780?}, 0xc005170000) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/values/validation/defaulting.go:47 +0x445 github.com/flant/addon-operator/pkg/values/validation.ApplyDefaults({0x3b63dc0?, 0xc000bec750?}, 0xc0010ed440) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/values/validation/defaulting.go:47 +0x445 github.com/flant/addon-operator/pkg/values/validation.ApplyDefaults({0x3b63dc0?, 0xc008b7de00?}, 0xc001cd6240) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/values/validation/defaulting.go:47 +0x445 github.com/flant/addon-operator/pkg/module_manager.(*ApplyDefaultsForModule).Transform(0xc0067cfc80, 0x3b03020?) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/module_manager/values_defaulting_transformers.go:36 +0x105 github.com/flant/addon-operator/pkg/module_manager.MergeLayers(0xc000cc682c?, {0xc008060ad8, 0x6, 0xc?}) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/module_manager/values_layered.go:27 +0x25c github.com/flant/addon-operator/pkg/module_manager.(*Module).Values(0xc000473800) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/module_manager/module.go:692 +0x345 github.com/flant/addon-operator/pkg/module_manager.(*ModuleManager).RunModuleHook(0xc000834ea0?, {0xc00375bdda, 0x1d}, {0x41004d6, 0xa}, {0xc0071e67e0?, 0x1, 0x1}, 0x41004d6?) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/module_manager/module_manager.go:800 +0x127 github.com/flant/addon-operator/pkg/addon-operator.(*AddonOperator).HandleModuleHookRun(0xc0004b47e0, {0x46292b8, 0xc00fb9b000}, 0xc0059eed80) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/addon-operator/operator.go:1513 +0xcdd github.com/flant/addon-operator/pkg/addon-operator.(*AddonOperator).TaskHandler(0xc0004b47e0, {0x46292b8, 0xc00fb9b000}) /go/pkg/mod/github.com/flant/addon-operator@v1.2.0/pkg/addon-operator/operator.go:914 +0x40b github.com/flant/shell-operator/pkg/task/queue.(*TaskQueue).Start.func1() /go/pkg/mod/github.com/flant/shell-operator@v1.3.1/pkg/task/queue/task_queue.go:406 +0x35e created by github.com/flant/shell-operator/pkg/task/queue.(*TaskQueue).Start /go/pkg/mod/github.com/flant/shell-operator@v1.3.1/pkg/task/queue/task_queue.go:387 +0x6f
Provided config values schema:
clusterIP: type: object properties: externalIPs: type: array default: []
There is no items schema in the externalIPs block, which causes panic. This PR only protects from the panic without adding schema validations.
items
externalIPs
Overview
Fixing a panic in runtime
What this PR does / why we need it
Example of the panic message:
Provided config values schema:
There is no
items
schema in theexternalIPs
block, which causes panic. This PR only protects from the panic without adding schema validations.Special notes for your reviewer