Commit Graph

74 Commits

Author SHA1 Message Date
liyuerich
8e97c0ff7d drop deprecated pointer package in controller
Signed-off-by: liyuerich <yue.li@daocloud.io>

Update job_controller.go

Signed-off-by: liyuerich <yue.li@daocloud.io>
2024-05-09 11:34:25 +08:00
Tomas Tormo
c856c412b9 Add util pkg to commonize job util functions 2024-05-07 09:27:46 +00:00
Michał Woźniak
3852d1c0c1
Make explicit check in CronJob if Job is successful before setting LastSuccessfulTime (#123380)
* Make explicit check in CronJob if Job is successful

before setting LastSuccessfulTime

* Review remarks for the CronJob

Co-authored-by: Filip Křepinský <fkrepins@redhat.com>

---------

Co-authored-by: Filip Křepinský <fkrepins@redhat.com>
2024-02-27 13:09:43 -08:00
Maciej Szulik
db8b303156
Modify mostRecentScheduleTime to return more detailed information about missed schedules
Initially this method was returning a number of missed schedules, but
that turned out to be not reliable for some complex schedules. For
example, those which are being run only during week days. The second
approach was to only return a boolean indicating the too many missed
information. It turns out that we need to return all three values:
none missed, few missed and many missed, to let consumers know what to
do, but don't leak the wrong number out of mostRecentScheduleTime.
2023-10-18 20:03:03 +02:00
Heba Elayoty
2fe38f93e5
feat: Append job creation timestamp to cronjob annotations (#118137)
* Append job name to job annotations

Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>

* Update annotation description, remove timezone, and fix time

Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>

* Remove unused ctx

Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>

* code review comments

Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>

* code review comments

Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>

* Add timezone back

Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>

---------

Signed-off-by: Heba Elayoty <hebaelayoty@gmail.com>
2023-07-06 14:39:04 -07:00
Maciej Szulik
1240a29af9
Hide numberOfMissedSchedules as an algorithm internal number 2023-07-05 16:58:28 +02:00
Maciej Szulik
af1c9e49c4
Update schedule logic to properly calculate missed schedules
Before this change we've assumed a constant time between schedule runs,
which is not true for cases like "30 6-16/4 * * 1-5".
The fix is to calculate the potential next run using the fixed schedule
as the baseline, and then go back one schedule back and allow the cron
library to calculate the correct time.

This approach saves us from iterating multiple times between last
schedule time and now, if the cronjob for any reason wasn't running for
significant amount of time.
2023-06-27 11:29:30 +02:00
Mengjiao Liu
6f2cd1b5bd Update pkg/controller/cronjob/ for contextual logging 2023-02-02 14:27:13 +08:00
Patrick Ohly
bc6c7fa912 logging: fix names of keys
The stricter checking with the upcoming logcheck v0.4.1 pointed out these names
which don't comply with our recommendations in
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md#name-arguments.
2023-01-23 14:24:29 +01:00
Maciej Szulik
be44d67566
Re-use common parts between getNextScheduleTime and nextScheduledTimeDuration
The two methods nextScheduledTimeDuration and getNextScheduleTime have a
lot of similarities, so this commit squashes the common parts together
along with getMostRecentScheduleTime to avoid code duplication.
2023-01-18 16:52:45 +01:00
Maciej Szulik
cb491a8d0f
Cleanups in controller utils
1. Squash two identical sorters byTime
2. Move helper for searching active jobs into utils to exist next to its
  counterpart
2023-01-18 13:40:23 +01:00
Jordan Liggitt
78cb3862f1
Fix indentation/spacing in comments to render correctly in godoc 2022-12-17 23:27:38 -05:00
Davanum Srinivas
a9593d634c
Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-07-26 13:14:05 -04: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
Kubernetes Prow Robot
8eef6438e6
Merge pull request #101055 from SimonCqk/master
fix: inaccurate miss schedule times of cronjob v2.
2021-06-15 08:38:01 -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
SimonCqk
b9d9cc38b5 fix: inaccurate miss schedule times of cronjob v2.
Signed-off-by: SimonCqk <cqk0100@gmail.com>
2021-04-13 13:59:27 +08:00
Maciej Szulik
78f51f8fa5
Switch cronjob controller to batch/v1 2021-03-05 14:03:34 +01:00
Alay Patel
6290a23ceb cronjob_controllerv2: gracefully handle 0 seconds between schedules 2021-02-24 13:48:56 -05:00
Alay Patel
0e171969e2 refine the test case for time drift, calculate next schedule with math 2021-02-22 12:11:04 -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
Kubernetes Prow Robot
fdbb960354
Merge pull request #90934 from iobuf/cronjob
CronJob: cleanup legacy ScheduledJob vars,docs
2020-05-19 20:35:11 -07:00
Davanum Srinivas
442a69c3bd
switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:27 -04:00
Zhou Peng
b33e202397 CronJob: cleanup legacy ScheduledJob vars,docs
Signed-off-by: Zhou Peng <p@ctriple.cn>
2020-05-10 00:45:21 +08:00
wojtekt
ccded14941 Eliminate some default conversions 2019-11-06 14:08:15 +01:00
David Xia
fabfd950b1
cleanup: fix some log and error capitalizations
Part of https://github.com/kubernetes/kubernetes/issues/15863
2019-07-20 18:26:16 -04:00
Tom Wanielista
d0cfc49704 Avoid panic in cronjob sorting
This change handles the case where the ith cronjob may have its start
time set to nil.

Previously, the Less method could cause a panic in case the ith
cronjob had its start time set to nil, but the jth cronjob did not. It
would panic when calling Before on a nil StartTime.
2019-03-30 12:43:14 -04:00
Peter McAlpine
ac88e13821 Fix lint warnings in pkg/controller/cronjob. 2019-03-19 14:36:26 -04:00
Davanum Srinivas
954996e231
Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135
2018-11-10 07:50:31 -05:00
Guoliang Wang
b1ac6df4dc remove unused code of (pkg/controller) 2018-10-09 08:15:30 +08:00
Kubernetes Submit Queue
971bd430d3
Merge pull request #61013 from andyxning/cronjob_remove_getNextStartTimeAfter
Automatic merge from submit-queue (batch tested with PRs 60632, 60806, 59471, 61251, 61013). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

cronjob_remove_getNextStartTimeAfter

**What this PR does / why we need it**:
`getNextStartTimeAfter` has not been used anywhere in Kubernetes and as it is a inter-pkg method, it is safe to remove it.
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2018-03-21 16:01:23 -07:00
Damien Mathieu
e8efc51c1c remove todo suggesting to add the cronjob start time 2018-03-19 19:22:14 +01:00
Damien Mathieu
c669ce440c remove todo to consider adding the cronjob name as a label
See #59473
2018-03-19 19:22:14 +01:00
Andy Xie
8d16742a32 cronjob_remove_getNextStartTimeAfter 2018-03-11 11:49:11 +08:00
Jun Xiang Tee
efbfead4ef remove created-by annotation 2017-10-30 12:49:44 -07:00
Dr. Stefan Schimanski
7773a30f67 pkg/api/legacyscheme: fixup imports 2017-10-18 17:23:55 +02:00
zhangxiaoyu-zidif
d0982ba539 fix comment for cronjob utils.go 2017-09-04 21:49:45 +08:00
Maciej Szulik
6962427b35
Enable batch/v1beta1.CronJobs by default 2017-09-03 11:17:33 +02:00
Antoine Pelisse
d7eec6b51d Revert "Enable batch/v1beta1.CronJobs by default" 2017-08-31 09:54:16 -07:00
Maciej Szulik
2de214b044
Enable batch/v1beta1.CronJobs by default 2017-08-29 09:31:39 +02:00
Kubernetes Submit Queue
1d5b365ed5 Merge pull request #50213 from zhangxiaoyu-zidif/fix-comment-cronjob-utils
Automatic merge from submit-queue (batch tested with PRs 50213, 50707, 49502, 51230, 50848)

Fix comment of cronjob utils.go

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes https://github.com/kubernetes/kubernetes/issues/50951

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-08-25 01:10:28 -07:00
gmarek
0504cfbc25 Make metav1.(Micro)?Time functions take pointers 2017-08-17 11:24:28 +02:00
zhangxiaoyu-zidif
71501d0304 do-rebase 2017-08-12 13:56:26 +08:00
Mikhail Mazurskiy
042b5642b9
Migrate to NewControllerRef from meta/v1 package 2017-08-06 22:43:46 +10:00
Mikhail Mazurskiy
b28a83a4cf
Migrate to GetControllerOf from meta/v1 package 2017-08-06 22:41:58 +10:00
Kubernetes Submit Queue
0b9aa05633 Merge pull request #48141 from ankon/patch-2
Automatic merge from submit-queue

Fix typo

**What this PR does / why we need it**: Fix trivial typo in comment.
2017-08-05 06:12:57 -07:00
Dr. Stefan Schimanski
5925a0a1df Move pkg/api/v1/ref -> client-go/tools/reference 2017-07-18 22:45:43 +02:00