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 }