openyurtio / yurt-app-manager

The workload controller manager from NodePool level in OpenYurt cluster
Apache License 2.0
6 stars 1 forks source link

[BUG] nil pointer dereference error if create yurtappdaemon before deploy yurt-app-manager #137

Closed Congrool closed 1 year ago

Congrool commented 1 year ago

What happened:

yurt-app-manager is always in CrashLoopBackOff, and the error log:

I0202 08:51:21.262542       1 yurtappdaemon_controller.go:129] Reconcile YurtAppDaemon kube-system/pool-coordinator
2023-02-02T08:51:21.262Z        INFO    controller.yurtappset-controller        Starting workers        {"worker count": 3}
I0202 08:51:21.364566       1 revision.go:50] List controller revision of YurtAppDaemon kube-system/pool-coordinator: count 0
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x155e496]

goroutine 529 [running]:
github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/yurtappdaemon.(*ReconcileYurtAppDaemon).cleanExpiredRevision(0x1b7cb40, 0xc000117200, 0x0)
        /build/pkg/yurtappmanager/controller/yurtappdaemon/revision.go:152 +0x36
github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/yurtappdaemon.(*ReconcileYurtAppDaemon).constructYurtAppDaemonRevisions(0xc000208510, 0xc00018d380)
        /build/pkg/yurtappmanager/controller/yurtappdaemon/revision.go:87 +0xd1
github.com/openyurtio/yurt-app-manager/pkg/yurtappmanager/controller/yurtappdaemon.(*ReconcileYurtAppDaemon).Reconcile(0xc000208510, {0xc000d5c210, 0x1739980}, {{{0xc000da0610, 0x1828260}, {0xc000da05f0, 0xc000a08000}}})
        /build/pkg/yurtappmanager/controller/yurtappdaemon/yurtappdaemon_controller.go:146 +0x1dc
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0xc000354140, {0x1b81218, 0xc000d5c210}, {{{0xc000da0610, 0x1828260}, {0xc000da05f0, 0xc000360600}}})
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.10.3/pkg/internal/controller/controller.go:114 +0x222
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc000354140, {0x1b81170, 0xc0005a1140}, {0x17a8260, 0xc000db8020})
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.10.3/pkg/internal/controller/controller.go:311 +0x2f2
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc000354140, {0x1b81170, 0xc0005a1140})
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.10.3/pkg/internal/controller/controller.go:266 +0x205
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.10.3/pkg/internal/controller/controller.go:227 +0x85
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.10.3/pkg/internal/controller/controller.go:223 +0x356

What you expected to happen:

yurt-app-manager should be in Running status.

How to reproduce it (as minimally and precisely as possible):

  1. apply crds that under https://github.com/openyurtio/yurt-app-manager/tree/master/charts/yurt-app-manager/crds
  2. create pool-coordinator with yurtappdaemon
  3. helm install yurt-app-manager -n kube-system ./charts/yurt-app-manager --set image.tag=latest

Anything else we need to know?:

yurt-app-manager version:

yurt-app-manager version: projectinfo.Info{GitVersion:"v0.6.0", GitCommit:"d363b43", BuildDate:"2023-01-18T02:02:08Z", GoVersion:"go1.17.1", Compiler:"gc", Platform:"linux/amd64"}

And if we deploy yurt-app-manager first, then create the pool-coordinator yurtappdaemon, yurt-app-manager can work.

others

/kind bug

rambohe-ch commented 1 year ago

@kadisi PTAL

gbtyy commented 1 year ago

The reason is that the attribute revisionHistoryLimit is missing, adding the attribute revisionHistoryLimit to yurtappdaemon can solve the problem

rambohe-ch commented 1 year ago

@Congrool As @gbtyy 's reply, this problem has been solved. and i will close this issue.

by the way, yurtappdaemon has been migrated into yurt-manager component, and revisionHistoryLimit will be set with a default value if it is nil. the code is here: https://github.com/openyurtio/openyurt/blob/master/pkg/yurtmanager/webhook/yurtappdaemon/v1alpha1/yurtappdaemon_default.go#L38