gpt4 book ai didi

kubernetes - Kubernetes cronjobs `startingDeadlineSeconds` 到底是什么意思?

转载 作者:行者123 更新时间:2023-12-04 01:39:13 26 4
gpt4 key购买 nike

在 Kubernetes cronjobs , 在 limitations section 中有说明那

Jobs may fail to run if the CronJob controller is not running or broken for a span of time from before the start time of the CronJob to start time plus startingDeadlineSeconds, or if the span covers multiple start times and concurrencyPolicy does not allow concurrency.



我从中了解到的是,如果 startingDeadlineSeconds设置为 10并且cronjob由于某种原因无法在预定的时间启动,那么只要这些 10仍然可以尝试重新启动。然而,在 10 之后,秒还没有过去。秒,它肯定不会启动,这是正确的吗?

另外,如果我有 concurrencyPolicy设置为 Forbid ,如果一个 cronjob 已经在运行,K8s 是否将其视为失败?

最佳答案

在调查了 Kubernetes repo 的代码库之后,所以这就是 CronJob Controller 的工作方式:

  • CronJob Controller will check the every 10 seconds给定 Kubernetes 客户端中的 cronjob 列表。
  • 对于每个 CronJob,它会检查它在 lastScheduleTime 的持续时间内错过了多少计划。直到现在。如果超过100 missed schedules ,然后它不会启 Action 业并记录事件:
    "FailedNeedsStart", "Cannot determine if job needs to be started. Too many missed start time (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew."

  • 重要 需要注意的是,如果字段 startingDeadlineSeconds设置(不是 nil ),它将从 startingDeadlineSeconds 的值中计算有多少丢失的作业发生直到现在。例如,如果 startingDeadlineSeconds = 200 , 会统计上次 200 发生了多少个漏掉的作业秒。计算可以找到多少错过的时间表的确切实现 here .
  • 如果上一步错过的计划不超过 100 个,CronJob Controller 将检查时间 now不是在它的时代之后 scheduledTime + startingDeadlineSeconds ,即现在开始工作还为时不晚(超过了截止日期)。如果还不算太晚,CronJob Controller 将继续尝试启动该作业。但是,如果已经太晚了,则它不会启 Action 业并记录事件:
    "Missed starting window for {cronjob name}. Missed scheduled time to start a job {scheduledTime}"

  • 也是 重要 需要注意的是,如果字段 startingDeadlineSeconds设置(不是 nil ),那么这意味着根本没有设置截止日期,这意味着 CronJob Controller 将尝试启动任何作业,而不检查它是否稍后。

    因此,回答上述问题:

    1. 如果startingDeadlineSeconds 设置为10 并且cronjob 由于某种原因无法在预定时间启动,那么只要这10 秒还没有过去,它仍然可以尝试再次启动,但是,在10 秒之后,它肯定不会启动,这是正确的吗?

    CronJob Controller 将尝试启动该作业,如果它的调度时间后 10 秒还没有过去,它将被成功调度。但是,如果截止日期已过,则不会在此运行中启动,并且在以后的执行中将计为错过的计划。

    2. 如果我将 concurrencyPolicy 设置为 Forbid ,如果一个 cronjob 试图被调度,当已经有一个 cronjob 正在运行时,K8s 是否将其视为失败?

    是的,它将被视为错过的时间表。由于错过的时间表是按照我在上面第 2 点中所述的方式计算的。

    关于kubernetes - Kubernetes cronjobs `startingDeadlineSeconds` 到底是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51065538/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com