From 75bd0b83a479997da1940e048d5161b11cecb303 Mon Sep 17 00:00:00 2001 From: Cheng Wang Date: Thu, 7 Sep 2023 20:01:58 +0800 Subject: [PATCH] fix: Workflow controller crash on nil pointer (#11770) --- workflow/controller/healthz.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/workflow/controller/healthz.go b/workflow/controller/healthz.go index a0dcc92b8377..b1d882b40c9c 100644 --- a/workflow/controller/healthz.go +++ b/workflow/controller/healthz.go @@ -33,6 +33,11 @@ func (wfc *WorkflowController) Healthz(w http.ResponseWriter, r *http.Request) { if err != nil { return err } + // the wfc.wfInformer is nil if it is not the leader + if wfc.wfInformer == nil { + log.Info("healthz: current pod is not the leader") + return nil + } lister := v1alpha1.NewWorkflowLister(wfc.wfInformer.GetIndexer()) list, err := lister.Workflows(wfc.managedNamespace).List(seletor) if err != nil {