zalando / zalando/postgres-operator
Operator 1.6.1 panic if we don't respect name convention
Open
Nobody has claimed this yet.
enhancement
good first issue
- Dominant language
- Go
- Stars
- 5.2k
- Forks
- 1.1k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 3
Description
- Which image of the operator are you using? registry.opensource.zalan.do/acid/postgres-operator:v1.6.1
- Where do you run it - cloud or metal? Kubernetes or OpenShift? Bare Metal K8s
- Are you running Postgres Operator in production? yes
- Type of issue? Bug report
I've created a new CR postgres without reading documentation about name-convention between teamId and CR name: my bad.
The operator crash with panic on nil dereference !!!
It should refuse my CR by doing nothing.
Here logs of operator
time="2021-03-19T16:16:37Z" level=error msg="could not get reference for Postgresql CR operator-postgres/my-pg-db: no kind is registered for the type v1.Postgresql in scheme \"k8s.io/client-go/kubernetes/scheme/register.go:72\"" pkg=controller
E0319 16:16:37.599020 1 runtime.go:78] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference)
goroutine 97 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic(0x1be2a80, 0x2e0b200)
/workspace/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:74 +0x95
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
/workspace/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:48 +0x89
panic(0x1be2a80, 0x2e0b200)
/usr/local/go/src/runtime/panic.go:969 +0x1b9
k8s.io/client-go/tools/record.(*recorderImpl).makeEvent(0xc00047c240, 0x0, 0x0, 0x1e7c762, 0x7, 0x1e7aacb, 0x6, 0xc000a10c60, 0x24, 0xc023b1e3ff)
/workspace/vendor/k8s.io/client-go/tools/record/event.go:362 +0x51
k8s.io/client-go/tools/record.(*recorderImpl).generateEvent(0xc00047c240, 0x2159b60, 0x0, 0x0, 0xc00d517963b1e3ff, 0x23628d1913, 0x2e2f8a0, 0x1e7c762, 0x7, 0x1e7aacb, ...)
/workspace/vendor/k8s.io/client-go/tools/record/event.go:338 +0x359
k8s.io/client-go/tools/record.(*recorderImpl).Event(0xc00047c240, 0x2159b60, 0x0, 0x1e7c762, 0x7, 0x1e7aacb, 0x6, 0xc000a10c60, 0x24)
/workspace/vendor/k8s.io/client-go/tools/record/event.go:349 +0xc5
k8s.io/client-go/tools/record.(*recorderImpl).Eventf(0xc00047c240, 0x2159b60, 0x0, 0x1e7c762, 0x7, 0x1e7aacb, 0x6, 0x1e780ae, 0x2, 0xc000436860, ...)
/workspace/vendor/k8s.io/client-go/tools/record/event.go:353 +0xca
github.com/zalando/postgres-operator/pkg/controller.(*Controller).queueClusterEvent(0xc000092380, 0x0, 0xc00093a400, 0x1e784bc, 0x3)
/workspace/pkg/controller/postgresql.go:446 +0x70a
github.com/zalando/postgres-operator/pkg/controller.(*Controller).postgresqlAdd(0xc000092380, 0x1e3b8c0, 0xc00093a400)
/workspace/pkg/controller/postgresql.go:506 +0x85
k8s.io/client-go/tools/cache.ResourceEventHandlerFuncs.OnAdd(...)
/workspace/vendor/k8s.io/client-go/tools/cache/controller.go:231
k8s.io/client-go/tools/cache.(*processorListener).run.func1()
/workspace/vendor/k8s.io/client-go/tools/cache/shared_informer.go:777 +0xc2
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc000132760)
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:155 +0x5f
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc0005e9f60, 0x2149660, 0xc000407290, 0x1b8fc01, 0xc00050e300)
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:156 +0xad
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc000132760, 0x3b9aca00, 0x0, 0xc00d51558569a501, 0xc00050e300)
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133 +0x98
k8s.io/apimachinery/pkg/util/wait.Until(...)
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:90
k8s.io/client-go/tools/cache.(*processorListener).run(0xc000696000)
/workspace/vendor/k8s.io/client-go/tools/cache/shared_informer.go:771 +0x95
k8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1(0xc0000f41b0, 0xc0004030e0)
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:73 +0x51
created by k8s.io/apimachinery/pkg/util/wait.(*Group).Start
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:71 +0x65
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x18c89d1]
goroutine 97 [running]:
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
/workspace/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:55 +0x10c
panic(0x1be2a80, 0x2e0b200)
/usr/local/go/src/runtime/panic.go:969 +0x1b9
k8s.io/client-go/tools/record.(*recorderImpl).makeEvent(0xc00047c240, 0x0, 0x0, 0x1e7c762, 0x7, 0x1e7aacb, 0x6, 0xc000a10c60, 0x24, 0xc023b1e3ff)
/workspace/vendor/k8s.io/client-go/tools/record/event.go:362 +0x51
k8s.io/client-go/tools/record.(*recorderImpl).generateEvent(0xc00047c240, 0x2159b60, 0x0, 0x0, 0xc00d517963b1e3ff, 0x23628d1913, 0x2e2f8a0, 0x1e7c762, 0x7, 0x1e7aacb, ...)
/workspace/vendor/k8s.io/client-go/tools/record/event.go:338 +0x359
k8s.io/client-go/tools/record.(*recorderImpl).Event(0xc00047c240, 0x2159b60, 0x0, 0x1e7c762, 0x7, 0x1e7aacb, 0x6, 0xc000a10c60, 0x24)
/workspace/vendor/k8s.io/client-go/tools/record/event.go:349 +0xc5
k8s.io/client-go/tools/record.(*recorderImpl).Eventf(0xc00047c240, 0x2159b60, 0x0, 0x1e7c762, 0x7, 0x1e7aacb, 0x6, 0x1e780ae, 0x2, 0xc000436860, ...)
/workspace/vendor/k8s.io/client-go/tools/record/event.go:353 +0xca
github.com/zalando/postgres-operator/pkg/controller.(*Controller).queueClusterEvent(0xc000092380, 0x0, 0xc00093a400, 0x1e784bc, 0x3)
/workspace/pkg/controller/postgresql.go:446 +0x70a
github.com/zalando/postgres-operator/pkg/controller.(*Controller).postgresqlAdd(0xc000092380, 0x1e3b8c0, 0xc00093a400)
/workspace/pkg/controller/postgresql.go:506 +0x85
k8s.io/client-go/tools/cache.ResourceEventHandlerFuncs.OnAdd(...)
/workspace/vendor/k8s.io/client-go/tools/cache/controller.go:231
k8s.io/client-go/tools/cache.(*processorListener).run.func1()
/workspace/vendor/k8s.io/client-go/tools/cache/shared_informer.go:777 +0xc2
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc000132760)
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:155 +0x5f
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc0005e9f60, 0x2149660, 0xc000407290, 0x1b8fc01, 0xc00050e300)
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:156 +0xad
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc000132760, 0x3b9aca00, 0x0, 0xc00d51558569a501, 0xc00050e300)
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133 +0x98
k8s.io/apimachinery/pkg/util/wait.Until(...)
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:90
k8s.io/client-go/tools/cache.(*processorListener).run(0xc000696000)
/workspace/vendor/k8s.io/client-go/tools/cache/shared_informer.go:771 +0x95
k8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1(0xc0000f41b0, 0xc0004030e0)
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:73 +0x51
created by k8s.io/apimachinery/pkg/util/wait.(*Group).Start
/workspace/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:71 +0x65
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pkg/controller/postgresql.go at queueClusterEvent (line 446) and postgresqlAdd (line 506), using the reported malformed Postgresql CR and panic trace as the reproduction case. Confirm that a CR violating the teamId/name convention is refused without a nil-pointer panic or operator crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes, postgresql
- Domain
- databases, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100