ITADN

panic when create resource already exists

#1765Closedlance5890 创建于 2024-07-22
lifecycle/rotten
L
lance5890commented
- when use library to create resource, but when the resource is already exists, it will panic, such as ``` Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: E0709 22:31:56.271679 1 runtime.go:78] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: goroutine 104 [running]: Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/runtime.logPanic({0x14a8c80, 0x2504150}) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:74 +0x85 Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0x4c4f05}) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:48 +0x75 Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: panic({0x14a8c80, 0x2504150}) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /usr/local/go/src/runtime/panic.go:1038 +0x215 Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/github.com/openshift/library-go/pkg/assets/create.create({0x186dde8, 0xc0000458c0}, 0xc000132000, {0x183eca0, 0xc000282530}, {0x187de60, 0xc0007e87f8}, {{0x0, 0x0, 0x0}, ...}) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/github.com/openshift/library-go/pkg/assets/create/creater.go:214 +0x10f0 Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/github.com/openshift/library-go/pkg/assets/create.EnsureManifestsCreated.func1() Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/github.com/openshift/library-go/pkg/assets/create/creater.go:84 +0x23e Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait.ConditionFunc.WithContext.func1({0xc0004b7f20, 0xc000529268}) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:217 +0x1b Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait.runConditionWithCrashProtectionWithContext({0x186dd78, 0xc000eab300}, 0x0) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:230 +0x7c Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait.WaitForWithContext({0x186dd78, 0xc000eab300}, 0xc0000bd6c8, 0x7d7eaa) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:657 +0x118 Jul 09 22:31:56 localhost.localdomain cluster-bootstrap[7822]: github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/runtime.logPanic({0x14a8c80, 0x2504150}) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait.poll({0x186dd78, 0xc000eab300}, 0x90, 0x7d6de5, 0xc00002f450) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:591 +0x9a Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait.PollImmediateUntilWithContext({0x186dd78, 0xc000eab300}, 0x90, 0xc000101400) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:542 +0x49 Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait.PollImmediateUntil(0xc0000458c0, 0x11, 0x0) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:533 +0x7c Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/vendor/github.com/openshift/library-go/pkg/assets/create.EnsureManifestsCreated({0x186dde8, 0xc0000458c0}, {0xc0002bc438, 0x11}, 0x689499, {{0x0, 0x0, 0x0}, 0x1, {0x183f400, ...}}) Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/vendor/github.com/openshift/library-go/pkg/assets/create/creater.go:72 +0x38f Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: github.com/openshift/cluster-bootstrap/pkg/start.(*startCommand).Run.func4.1() Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/pkg/start/start.go:151 +0x189 Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: created by github.com/openshift/cluster-bootstrap/pkg/start.(*startCommand).Run.func4 Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: /go/src/github.com/openshift/cluster-bootstrap/pkg/start/start.go:149 +0x10f Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: panic: runtime error: invalid memory address or nil pointer dereference [recovered] Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: panic: runtime error: invalid memory address or nil pointer dereference Jul 09 22:31:56 localhost.localdomain bootkube.sh[7729]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1168b70] ``` - that is because when create resource err, the 'incluster' could be nil https://github.com/openshift/library-go/blob/e0aa70d556789b3ff5e9af85e838320b3063aa14/pkg/assets/create/creater.go#L195 - which could lead to the https://github.com/openshift/library-go/blob/e0aa70d556789b3ff5e9af85e838320b3063aa14/pkg/assets/create/creater.go#L214 panic
关闭于 2024-12-20 4 条评论