diff --git a/pkg/controlplane/controller/leaderelection/run_with_leaderelection.go b/pkg/controlplane/controller/leaderelection/run_with_leaderelection.go index f34c5a2e405..0b73170d1f7 100644 --- a/pkg/controlplane/controller/leaderelection/run_with_leaderelection.go +++ b/pkg/controlplane/controller/leaderelection/run_with_leaderelection.go @@ -50,7 +50,9 @@ func RunWithLeaderElection(ctx context.Context, config *rest.Config, newRunnerFn run(ctx, 1) }, OnStoppedLeading: func() { - cancel() + if cancel != nil { + cancel() + } }, }