What steps did you take and what happened:
I deployed the below nightly backup schedule YAML via kubectl apply. This immediately triggered a new backup to start, instead of waiting for midnight! It appears the backup is also started at the scheduled time.
apiVersion: velero.io/v1
kind: Schedule
metadata:
name: daily
namespace: velero
spec:
schedule: '@midnight'
template:
hooks: {}
includedNamespaces:
- '*'
ttl: 720h0m0s
The same thing happens when an existing schedule is updated, for example when changing the schedule from @every 24h to @midnight. Instead of waiting till midnight, it starts right away then also runs at midnight.
What did you expect to happen:
I expected that creating the schedule resource do nothing, except create a cronjob. The schedule should then trigger only at the scheduled times. I.e. in case of @midnight it should start its initial run only when the time first passes midnight.
The output of the following commands will help us better understand what's going on:
Relevant lines are from kubectl logs deployment/velero -n velero. I edited the daily schedule to run at @midnight at 7:55 UTC. Noteworthy is the line: "Schedule is due, submitting Backup"
time="2020-04-14T06:11:20Z" level=info msg="Done checking for expired DeleteBackupRequests" controller=backup-deletion logSource="pkg/controller/backup_deleti
on_controller.go:484"
time="2020-04-14T07:11:20Z" level=info msg="Checking for expired DeleteBackupRequests" controller=backup-deletion logSource="pkg/controller/backup_deletion_co
ntroller.go:456"
time="2020-04-14T07:11:20Z" level=info msg="Done checking for expired DeleteBackupRequests" controller=backup-deletion logSource="pkg/controller/backup_deleti
on_controller.go:484"
time="2020-04-14T07:55:20Z" level=info msg="Schedule is due, submitting Backup" controller=schedule logSource="pkg/controller/schedule_controller.go:260" next
RunTime="2020-04-14 00:00:00 +0000 UTC" schedule=velero/daily
time="2020-04-14T07:55:20Z" level=info msg="Setting up backup log" backup=velero/daily-20200414075520 controller=backup logSource="pkg/controller/backup_contr
oller.go:472"
time="2020-04-14T07:55:20Z" level=info msg="Setting up backup temp file" backup=velero/daily-20200414075520 logSource="pkg/controller/backup_controller.go:494
"
time="2020-04-14T07:55:20Z" level=info msg="Setting up plugin manager" backup=velero/daily-20200414075520 logSource="pkg/controller/backup_controller.go:501"
time="2020-04-14T07:55:20Z" level=info msg="Getting backup item actions" backup=velero/daily-20200414075520 logSource="pkg/controller/backup_controller.go:505
"
time="2020-04-14T07:55:20Z" level=info msg="Setting up backup store" backup=velero/daily-20200414075520 logSource="pkg/controller/backup_controller.go:511"
time="2020-04-14T07:55:21Z" level=info msg="Writing backup version file" backup=velero/daily-20200414075520 logSource="pkg/backup/backup.go:213"
time="2020-04-14T07:55:21Z" level=info msg="Including namespaces: *" backup=velero/daily-20200414075520 logSource="pkg/backup/backup.go:219"
time="2020-04-14T07:55:21Z" level=info msg="Excluding namespaces: <none>" backup=velero/daily-20200414075520 logSource="pkg/backup/backup.go:220"
time="2020-04-14T07:55:21Z" level=info msg="Including resources: *" backup=velero/daily-20200414075520 logSource="pkg/backup/backup.go:223"
time="2020-04-14T07:55:21Z" level=info msg="Excluding resources: <none>" backup=velero/daily-20200414075520 logSource="pkg/backup/backup.go:224"
Environment:
velero version):Client:
Version: v1.3.1
Git commit: -
Server:
Version: v1.3.1
velero client config get features):features: <NOT SET>kubectl version):Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.3", GitCommit:"06ad960bfd03b39c8310aaf92d1e7c12ce618213", GitTreeState:"clean", BuildDate:"2020-02-13T18:06:54Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14+", GitVersion:"v1.14.10-gke.27", GitCommit:"145f9e21a4515947d6fb10819e5a336aff1b6959", GitTreeState:"clean", BuildDate:"2020-02-21T18:01:40Z", GoVersion:"go1.12.12b4", Compiler:"gc", Platform:"linux/amd64"}
GKE 1.14.xGoogle Cloud Platform GKEdefinitely agree this is a bug for schedules that are supposed to run at a fixed time each day, like the midnight schedule
Fixing this could be an opportunity to get rid of our own cron logic, and change the schedule controller to just create a Kubernetes CronJob.
this is actually a dupe of #1980, so I'm going to close this one out in favor of that existing issue.
Most helpful comment
Fixing this could be an opportunity to get rid of our own cron logic, and change the schedule controller to just create a Kubernetes
CronJob.