Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job's backoffLimit needs to take number of failed pods into account #70251

Closed
janetkuo opened this issue Oct 25, 2018 · 10 comments
Closed

Job's backoffLimit needs to take number of failed pods into account #70251

janetkuo opened this issue Oct 25, 2018 · 10 comments
Labels
area/reliability area/workload-api/job kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/apps Categorizes an issue or PR as relevant to SIG Apps.
Projects

Comments

@janetkuo
Copy link
Member

janetkuo commented Oct 25, 2018

Job controller uses NumRequeues of the Job workqueue to calculate backoffLimit. This makes backoffLimit unpredictable especially when a job with parallelism larger than 1 and when its restartPolicy is Never.

Take this job for example:

apiVersion: batch/v1
kind: Job
metadata:
  name: error
spec:
  backoffLimit: 10
  parallelism: 10
  template:
    metadata:
      name: job
    spec:
      restartPolicy: Never
      containers:
        - name: job
          image: busybox
          args:
            - /bin/sh
            - -c
            - exit 1

The job will eventually fail after it creates 64 failed pods, instead of 10 failed pods.

  [...]
  status:
    conditions:
    - lastProbeTime: "2018-10-25T18:12:06Z"
      lastTransitionTime: "2018-10-25T18:12:06Z"
      message: Job has reached the specified backoff limit
      reason: BackoffLimitExceeded
      status: "True"
      type: Failed
    failed: 64

If restartPolicy is set to OnFailure, total number of container restarts count will be taken into account. This seems more predictable. However, if we change the restartPolicy of the same Job to OnFailure, all the failed Pods will be deleted when they are restarted:

jm.deleteJobPods(&job, activePods, errCh)

The job will fail when its creates 10 failed pods, but will end up with 0 pods.

@kubernetes/sig-apps-bugs @soltysh @kow3ns

/king bug

@janetkuo janetkuo added sig/apps Categorizes an issue or PR as relevant to SIG Apps. area/workload-api/job labels Oct 25, 2018
@janetkuo janetkuo added this to Backlog in Workloads via automation Oct 25, 2018
@janetkuo janetkuo added the kind/bug Categorizes issue or PR as related to a bug. label Oct 25, 2018
@soltysh
Copy link
Contributor

soltysh commented Oct 26, 2018

@janetkuo wouldn't it be better to rewrite the backoff as it is today (that's why #64787 was created) instead of adding more hacks to the current implementation? How about we try to design the new implementation and fix that for 1.14?

@janetkuo
Copy link
Member Author

janetkuo commented Oct 26, 2018

@soltysh I'm not trying to add hack to backoff but want to remove the use of NumRequeues completely.

Based on original design doc of backoffLimit https://github.com/kubernetes/community/blob/master/contributors/design-proposals/apps/job.md#backoff-policy-and-failed-pod-limit:

For Never we count actual pod failures (reflected in .status.failed field). With OnFailure, we take an approximate value of pod restarts (as reported in .status.containerStatuses[*].restartCount).

RestartPolicy: OnFailure jobs are implemented as described above, but RestartPolicy: Never jobs don't count actual pod failures. Is there any reason it's implemented with NumRequeues instead of comparing # of failed pods with .status.failed?

I also find it vague and confusing what "number of job restarts" actually mean, especially for jobs with RestartPolicy: Never and/or run more than one pods in parallel. We need to describe the behavior more precisely.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 27, 2019
@janetkuo janetkuo removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 25, 2019
@stojan-jovic
Copy link

I also experiencing this issue. Is #64787 in plans for any coming release?

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 31, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Nov 30, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Workloads automation moved this from Backlog to Done Dec 30, 2019
@yasongxu
Copy link
Contributor

/reopen

any plan for this issue ? #64787,same problem at k8s v1.19 version

@k8s-ci-robot
Copy link
Contributor

@yasongxu: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

any plan for this issue ? #64787,same problem at k8s v1.19 version

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/reliability area/workload-api/job kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. sig/apps Categorizes an issue or PR as relevant to SIG Apps.
Projects
Workloads
  
Done
Development

No branches or pull requests

7 participants