Fix potential bug with wrongly refreshed crons
This commit is contained in:
parent
da09b87020
commit
26e30f2f16
2 changed files with 16 additions and 2 deletions
|
@ -52,3 +52,11 @@ tasks:
|
|||
vars:
|
||||
DEPLOY_HOST: rosti-merkur
|
||||
GOARCH: amd64
|
||||
- task: deploy
|
||||
vars:
|
||||
DEPLOY_HOST: rosti-io
|
||||
GOARCH: amd64
|
||||
- task: deploy
|
||||
vars:
|
||||
DEPLOY_HOST: rosti-venus
|
||||
GOARCH: amd64
|
||||
|
|
|
@ -139,6 +139,8 @@ func (s *Scheduler) do(plan schedulerPlan, done chan schedulerPlan) {
|
|||
err = s.notifier.Notify(notifyURL)
|
||||
if err != nil {
|
||||
log.Printf(".. failed to notify %s: %s", notifyURL, err.Error())
|
||||
} else {
|
||||
log.Printf(".. notification sent to %s", notifyURL)
|
||||
}
|
||||
} else if notifyURL != "" && s.notifier == nil {
|
||||
log.Println("Warning: No notifier configured, skipping notification")
|
||||
|
@ -239,6 +241,7 @@ func (s *Scheduler) Run() error {
|
|||
}
|
||||
}
|
||||
|
||||
// Footprint is something like a hash of current config that is used to determine if the scheduler needs to be refreshed
|
||||
func (s *Scheduler) footprint(is []incus.Instance, vols []incus.Volume) string {
|
||||
footprint := ""
|
||||
for _, inst := range is {
|
||||
|
@ -283,6 +286,9 @@ func (s *Scheduler) setupInstanceSchedules(is []incus.Instance, vols []incus.Vol
|
|||
log.Println("Refreshing scheduler ..")
|
||||
|
||||
if s.cron != nil {
|
||||
for _, e := range s.cron.Entries() {
|
||||
s.cron.Remove(e.ID)
|
||||
}
|
||||
s.cron.Stop()
|
||||
}
|
||||
|
||||
|
@ -320,7 +326,7 @@ func (s *Scheduler) setupInstanceSchedules(is []incus.Instance, vols []incus.Vol
|
|||
if sen.Backup {
|
||||
log.Println(".. adding backup schedule for", vol.Project, vol.Pool, vol.Name, sen.BackupSchedule)
|
||||
_, err := s.cron.AddFunc(sen.BackupSchedule, func() {
|
||||
log.Printf(".. placing volume backup of %s%s%s into the queue", vol.Project, vol.Pool, vol.Name)
|
||||
log.Printf(".. placing volume backup of %s/%s/%s into the queue", vol.Project, vol.Pool, vol.Name)
|
||||
s.planner <- schedulerPlan{Volume: vol, Reason: planReasonBackupVolume}
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -331,7 +337,7 @@ func (s *Scheduler) setupInstanceSchedules(is []incus.Instance, vols []incus.Vol
|
|||
if sen.Sync {
|
||||
log.Println(".. adding sync schedule for", vol.Project, vol.Pool, vol.Name, sen.SyncSchedule)
|
||||
_, err := s.cron.AddFunc(sen.SyncSchedule, func() {
|
||||
log.Printf(".. placing volume sync of %s%s%s into the queue", vol.Project, vol.Pool, vol.Name)
|
||||
log.Printf(".. placing volume sync of %s/%s/%s into the queue", vol.Project, vol.Pool, vol.Name)
|
||||
s.planner <- schedulerPlan{Volume: vol, Reason: planReasonSyncVolume}
|
||||
})
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue