Commit Graph

32 Commits

Author SHA1 Message Date
Alvaro Aleman
6d0ac8c561 Use the generic/typed workqueue throughout
This change makes us use the generic workqueue throughout the project in
order to improve type safety and readability of the code.
2024-05-04 14:33:12 -04:00
Andrew Sy Kim
301aa69fec cronjob controller: ensure already existing jobs are added to Active list of cronjobs
Signed-off-by: Andrew Sy Kim <andrewsy@google.com>
2023-09-19 15:18:44 +00:00
Albert Sverdlov
a46bab6930
Fix a job quota related deadlock (#119776)
* Fix a job quota related deadlock

In case ResourceQuota is used and sets a max # of jobs, a CronJob may get
trapped in a deadlock:
  1. Job quota for a namespace is reached.
  2. CronJob controller can't create a new job, because quota is
     reached.
  3. Cleanup of jobs owned by a cronjob doesn't happen, because a
     control loop iteration is finished because of an error to create a
     job.

To fix this we stop early quitting from a control loop iteration when
cronjob reconciliation failed and always let old jobs to be cleaned up.

* Dont reorder imports

* Don't stop requeuing on reconciliation error

Previous code only logged the reconciliation error inside jm.sync() and
didn't return the reconciliation error to it's invoker
processNextWorkItem().

Adding a copy-paste back to avoid this issue.

* Remove copy-pasted cleanupFinishedJobs()

Now we always call jm.cleanupFinishedJobs() first and then
jm.syncCronJob().

We also extract cronJobCopy and updateStatus outside jm.syncCronJob
function and pass pointers to them in both jm.syncCronJob and
jm.cleanupFinishedJobs to make delayed updates handling more explicit
and not dependent on the order in which cleanupFinishedJobs and
syncCronJob are invoked.

* Return updateStatus bool instead of changing the reference

* Explicitly ignore err in tests to fix linter
2023-08-31 08:25:00 -07:00
Kubernetes Prow Robot
88c8bcbb4a
Merge pull request #115952 from pacoxu/cleanup-cronjob
cronjob: return immediately when failed to create job for the namespace is terminating
2023-07-18 21:28:02 -07:00
Paco Xu
ade63dd764 cronjob: add ut for namespace terminating cause no extra log 2023-03-23 21:40:33 +08:00
Maciej Szulik
1b825c179b
Promote CronJob TZ to GA 2023-03-07 12:58:57 +01:00
Mengjiao Liu
6f2cd1b5bd Update pkg/controller/cronjob/ for contextual logging 2023-02-02 14:27:13 +08:00
Kubernetes Prow Robot
6269784cd0
Merge pull request #109250 from d-honeybadger/fix-cronjob-scheduling-every-syntax
Fix requeueing of cronjobs with every-style schedule
2022-06-28 04:37:57 -07:00
Jordan Liggitt
495b01ef6c Move cron job feature gate to correct file 2022-04-03 22:56:01 -04:00
d-honeybadger
7ae21b9849 cronjob_controllerv2: fix requeueing of cronjobs with every-style schedule 2022-04-01 20:14:23 -04:00
Ross Peoples
dbb3906a09 Fix for timeZone validation and strategy 2022-03-29 11:40:34 -05:00
Ross Peoples
f3b928a23d Import tzdata in apiserver, CronJob.timeZone fixes 2022-03-28 16:33:05 -05:00
Ross Peoples
98837de446 TimeZone support for CronJobs 2022-03-28 16:33:00 -05:00
Kubernetes Prow Robot
343125cc6c
Merge pull request #107997 from d-honeybadger/fix-tracking-cronjob-owned-jobs
Fix cronjob status reconciliation when job template labels change
2022-02-23 07:14:18 -08:00
d-honeybadger
fb094dc44e cronjob_controllerv2: do not filter jobs to be reconciled by labels 2022-02-23 09:10:33 -05:00
jlsong01
d281e25426 Optimize cronjob controller status updates 2022-01-27 17:09:47 +08:00
jlsong01
79d921e040 readability enhancement for cj controller unit test 2022-01-20 23:10:10 +08:00
Mike Dame
80c01707e0
Wire contexts to Batch controllers (#105491)
* Wire contexts to Batch controllers

* (hold) feedback + updates that overlap with Apps controllers

* fixup errors
2021-11-10 14:56:46 -08:00
Maciej Szulik
5254493044
Remove old cronjob controller 2021-11-04 13:24:28 +01:00
Kubernetes Prow Robot
270b66fb94
Merge pull request #102642 from alaypatel07/lastSuccessfulTime
populate last successful time to cronjob status
2021-06-15 11:31:35 -07:00
Davanum Srinivas
4b36a5cbe9
Switch to github.com/robfig/cron/v3
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-06-14 19:03:03 -04:00
Alay Patel
92b52a4fb5 populate last successful time to cronjob status 2021-06-06 16:14:16 -04:00
Maciej Szulik
0a8417e161
Simplify cronjob v2 controller tests 2021-03-05 19:25:51 +01:00
Maciej Szulik
78f51f8fa5
Switch cronjob controller to batch/v1 2021-03-05 14:03:34 +01:00
mengjiao.liu
f80a799a45 modify the TestController2_updateCronJob test method description 2021-03-04 11:20:33 +08:00
Alay Patel
602435ccb9 cronjob: fix flaky unit test TestController2_updateCronJob 2021-03-01 15:45:32 -05:00
Kubernetes Prow Robot
c198632a12
Merge pull request #97098 from alaypatel07/cronjob-controller-2-follow-up-2
fix the case of time drift and re-implement next schedule calculation
2021-02-25 12:21:40 -08:00
Alay Patel
0e171969e2 refine the test case for time drift, calculate next schedule with math 2021-02-22 12:11:04 -05:00
pacoxu
81e0ebcde9 run cronjob every 1minute(means 1s) in UT 2021-02-02 18:54:50 +08:00
Alay Patel
d6ca5b8d14 handle the case for slow cronjob lister, add unit tests 2020-11-11 18:48:57 -05:00
Alay Patel
41c82e69ed convert to stardard lister, use []*batchv1.Job instead of []batchv1.Job 2020-11-11 18:48:57 -05:00
Alay Patel
8d7dd4415e add cronjob_controllerv2.go 2020-11-10 17:32:06 -05:00