Help me clear something regarding job and backoffLimit .
I have setup this job with a container that succeeds or fails randomly:
apiVersion: batch/v1 kind: Job metadata: name: test-job spec: backoffLimit: 2 completions: 4 parallelism: 1 template: spec: containers: - name: random-error image: kodekloud/random-error restartPolicy: Never
After running the job it fails but after creating 5 pods:
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal SuccessfulCreate 22m job-controller Created pod: test-job-h2mtj Normal SuccessfulCreate 21m job-controller Created pod: test-job-cqf6r Normal SuccessfulCreate 21m job-controller Created pod: test-job-bjfqh Normal SuccessfulCreate 21m job-controller Created pod: test-job-4fmp8 Normal SuccessfulCreate 20m job-controller Created pod: test-job-45llg Warning BackoffLimitExceeded 20m job-controller Job has reached the specified backoff limit
Im confused as to why the Job fails after creating 5 pods and not after 4 since the backoffLimit is set to 2 and the the 3rd and 4th pods exited with an error:
NAME READY STATUS RESTARTS AGE test-job-45llg 0/1 Error 0 20m test-job-4fmp8 0/1 Error 0 21m test-job-bjfqh 0/1 Error 0 21m test-job-cqf6r 0/1 Completed 0 21m test-job-h2mtj 0/1 Error 0 22m