Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leader election panic: nil pointer deref #6071

Closed
alexec opened this issue Jun 2, 2021 · 3 comments · Fixed by #6072
Closed

leader election panic: nil pointer deref #6071

alexec opened this issue Jun 2, 2021 · 3 comments · Fixed by #6072
Assignees
Labels
Milestone

Comments

@alexec
Copy link
Contributor

alexec commented Jun 2, 2021

k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
--
  | goroutine 129 [running]:
  | [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x19d03dc]
  | panic: runtime error: invalid memory address or nil pointer dereference
  | panic: runtime error: invalid memory address or nil pointer dereference [recovered]
  | /go/src/github.com/argoproj/argo-workflows/workflow/controller/controller.go:241 +0xfb8
  | created by github.com/argoproj/argo-workflows/v3/workflow/controller.(*WorkflowController).Run
  | /go/pkg/mod/k8s.io/client-go@v0.19.6/tools/leaderelection/leaderelection.go:222 +0x9c
  | k8s.io/client-go/tools/leaderelection.RunOrDie(0x206d8e0, 0xc00011fc40, 0x2079ce0, 0xc001e20500, 0x37e11d600, 0x2540be400, 0x12a05f200, 0xc0002118c0, 0xc001615c40, 0xc0015efd90, ...)
  | /go/pkg/mod/k8s.io/client-go@v0.19.6/tools/leaderelection/leaderelection.go:210 +0x15d
  | k8s.io/client-go/tools/leaderelection.(*LeaderElector).Run(0xc0016b8120, 0x206d8e0, 0xc001c6a100)
  | /go/pkg/mod/k8s.io/client-go@v0.19.6/tools/leaderelection/leaderelection.go:200 +0x29
  | k8s.io/client-go/tools/leaderelection.(*LeaderElector).Run.func1(0xc0016b8120)
  | /go/src/github.com/argoproj/argo-workflows/workflow/controller/controller.go:256 +0x7c
  | github.com/argoproj/argo-workflows/v3/workflow/controller.(*WorkflowController).Run.func2()
  | /usr/local/go/src/runtime/panic.go:969 +0x1b9
  | panic(0x1b6fb20, 0x2c9ca80)
  | /go/pkg/mod/k8s.io/apimachinery@v0.19.6/pkg/util/runtime/runtime.go:48 +0x89
  | k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
  | /go/pkg/mod/k8s.io/apimachinery@v0.19.6/pkg/util/runtime/runtime.go:74 +0x95
@alexec alexec added the type/bug label Jun 2, 2021
@alexec alexec added this to the v3.0 milestone Jun 2, 2021
@alexec
Copy link
Contributor Author

alexec commented Jun 2, 2021


				OnStoppedLeading: func() {
					logCtx.Info("stopped leading")
					cancel()
				},

cancel is nil.

@alexec
Copy link
Contributor Author

alexec commented Jun 2, 2021

Looking at the code, cancel is never set. It is always nil. StopLeading will always panic.

Because we have ReleaseOnCancel, We need

ctx, cancel := context.WithCancel(ctx)
	defer cancel()

As the second line of (wfc *WorkflowController) Run.

1 similar comment
@alexec
Copy link
Contributor Author

alexec commented Jun 2, 2021

Looking at the code, cancel is never set. It is always nil. StopLeading will always panic.

Because we have ReleaseOnCancel, We need

ctx, cancel := context.WithCancel(ctx)
	defer cancel()

As the second line of (wfc *WorkflowController) Run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants