Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Use schedule location during earliestTime calculations #6

Merged
merged 4 commits into from
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ test-codegen:
git diff --exit-code -- pkg/apis pkg/client

test: test-fmt test-codegen
go test $(TEST_FLAGS) ./...
go test $(TEST_FLAGS) ./...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ metadata:
name: hello
spec:
schedule: "*/1 * * * *"
timeZone: "Europe/Amsterdam"
timezone: "Europe/Amsterdam"
jobTemplate:
spec:
template:
Expand Down
2 changes: 1 addition & 1 deletion deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
- name: Time zone
type: string
description: The time zone the interval of a TZCronJob is calculated in
JSONPath: .spec.timeZone
JSONPath: .spec.timezone
- name: Last schedule
type: date
description: The last time a Job was scheduled by a TZCronJob
Expand Down
11 changes: 11 additions & 0 deletions deploy/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ spec:
name: cronjobber
spec:
serviceAccountName: cronjobber
securityContext:
fsGroup: 65534 #nobody
volumes:
- name: timezonedb
hostPath:
path: /usr/share/zoneinfo
type: Directory
containers:
- name: cronjobber
image: quay.io/hiddeco/cronjobber:0.1.0
Expand All @@ -25,3 +32,7 @@ spec:
memory: 64Mi
args:
- --log-level=info
volumeMounts:
- name: timezonedb
mountPath: /usr/share/zoneinfo
readOnly: true
4 changes: 2 additions & 2 deletions example/hello-tzc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ kind: TZCronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
timeZone: "Europe/Amsterdam"
schedule: "*/5 18 * * *"
timezone: "Europe/Amsterdam"
jobTemplate:
spec:
template:
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/cronjobber/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func getRecentUnmetScheduleTimes(sj cronjobberv1.TZCronJob, now time.Time) ([]ti

var earliestTime time.Time
if sj.Status.LastScheduleTime != nil {
earliestTime = sj.Status.LastScheduleTime.Time
earliestTime = sj.Status.LastScheduleTime.Time.In(now.Location())
} else {
// If none found, then this is either a recently created scheduledJob,
// or the active/completed info was somehow lost (contract for status
Expand All @@ -111,7 +111,7 @@ func getRecentUnmetScheduleTimes(sj cronjobberv1.TZCronJob, now time.Time) ([]ti
}
if sj.Spec.StartingDeadlineSeconds != nil {
// Controller is not going to schedule anything below this point
schedulingDeadline := now.Add(-time.Second * time.Duration(*sj.Spec.StartingDeadlineSeconds))
schedulingDeadline := now.Add(-time.Second * time.Duration(*sj.Spec.StartingDeadlineSeconds)).In(now.Location())

if schedulingDeadline.After(earliestTime) {
earliestTime = schedulingDeadline
Expand Down