From c885205b913f54fcef0e15709591845fc203d26c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 21 Sep 2025 19:48:11 -0400 Subject: [PATCH] refactor: respect the maintenance value of the cron task instead of skipping them The former method would omit the CronJob objects entirely, meaning a redeploy would be necessary to re-enable them. --- plugins/scheduler-k3s/template.go | 1 + plugins/scheduler-k3s/templates/chart/cron-job.yaml | 2 +- plugins/scheduler-k3s/triggers.go | 10 ++-------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/plugins/scheduler-k3s/template.go b/plugins/scheduler-k3s/template.go index 835e5f35d..17eafdde5 100644 --- a/plugins/scheduler-k3s/template.go +++ b/plugins/scheduler-k3s/template.go @@ -302,6 +302,7 @@ type ProcessCron struct { ID string `yaml:"id"` Schedule string `yaml:"schedule"` Suffix string `yaml:"suffix"` + Suspend bool `yaml:"suspend"` } type ProcessPortMap struct { diff --git a/plugins/scheduler-k3s/templates/chart/cron-job.yaml b/plugins/scheduler-k3s/templates/chart/cron-job.yaml index f44d40696..b5b4e8b88 100644 --- a/plugins/scheduler-k3s/templates/chart/cron-job.yaml +++ b/plugins/scheduler-k3s/templates/chart/cron-job.yaml @@ -135,6 +135,6 @@ spec: schedule: {{ $config.cron.schedule }} startingDeadlineSeconds: 60 successfulJobsHistoryLimit: 10 - suspend: false + suspend: {{ $config.cron.suspend }} timeZone: Etc/UTC {{- end }} diff --git a/plugins/scheduler-k3s/triggers.go b/plugins/scheduler-k3s/triggers.go index def82453f..efaba74b0 100644 --- a/plugins/scheduler-k3s/triggers.go +++ b/plugins/scheduler-k3s/triggers.go @@ -312,17 +312,10 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e workingDir := common.GetWorkingDir(appName, image) - allCronTasks, err := cron.FetchCronTasks(cron.FetchCronTasksInput{AppName: appName}) + cronTasks, err := cron.FetchCronTasks(cron.FetchCronTasksInput{AppName: appName}) if err != nil { return fmt.Errorf("Error fetching cron tasks: %w", err) } - // remove maintenance cron tasks - cronTasks := []cron.CronTask{} - for _, cronTask := range allCronTasks { - if !cronTask.Maintenance { - cronTasks = append(cronTasks, cronTask) - } - } domains := []string{} if _, ok := processes["web"]; ok { @@ -655,6 +648,7 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e ID: cronTask.ID, Schedule: cronTask.Schedule, Suffix: suffix, + Suspend: cronEntry.Maintenance, }, Labels: labels, ProcessType: ProcessType_Cron,