From a16f5b389415ccc1527023aad610a216725ac7a4 Mon Sep 17 00:00:00 2001 From: Thor <1187526662@qq.com> Date: Fri, 3 Jul 2020 16:32:43 +0800 Subject: [PATCH] fix issue 890 Signed-off-by: Thor <1187526662@qq.com> --- pkg/controllers/job/job_controller_actions.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/controllers/job/job_controller_actions.go b/pkg/controllers/job/job_controller_actions.go index 715c94a776c..5516f365e7c 100644 --- a/pkg/controllers/job/job_controller_actions.go +++ b/pkg/controllers/job/job_controller_actions.go @@ -22,7 +22,7 @@ import ( "sync" "sync/atomic" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog" @@ -149,8 +149,10 @@ func (cc *Controller) initiateJob(job *batch.Job) (*batch.Job, error) { klog.Infof("Current Version is: %d of job: %s/%s", job.Status.Version, job.Namespace, job.Name) job, err := cc.initJobStatus(job) if err != nil { - cc.recorder.Event(job, v1.EventTypeWarning, string(batch.JobStatusError), - fmt.Sprintf("Failed to initialize job status, err: %v", err)) + if job != nil { + cc.recorder.Event(job, v1.EventTypeWarning, string(batch.JobStatusError), + fmt.Sprintf("Failed to initialize job status, err: %v", err)) + } return nil, err }