From f1e3c0764c1e7bb25b61b2d6ed574da2b5399afe Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 21 Sep 2025 18:06:21 -0400 Subject: [PATCH] feat: expose the concurrency policy when fetching cron entries Also add some validation to ensure invalid values are not specified. --- plugins/cron/cron.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/cron/cron.go b/plugins/cron/cron.go index 1d02ade85..aa62ed75c 100644 --- a/plugins/cron/cron.go +++ b/plugins/cron/cron.go @@ -47,6 +47,9 @@ type CronTask struct { // Schedule is the cron schedule Schedule string `json:"schedule"` + // ConcurrencyPolicy is the concurrency policy for the cron command + ConcurrencyPolicy string `json:"concurrency_policy"` + // AltCommand is an alternate command to run AltCommand string `json:"-"` @@ -148,12 +151,19 @@ func FetchCronTasks(input FetchCronTasksInput) ([]CronTask, error) { maintenance = boolValue } } + if c.ConcurrencyPolicy == "" { + c.ConcurrencyPolicy = "allow" + } + if c.ConcurrencyPolicy != "allow" && c.ConcurrencyPolicy != "forbid" && c.ConcurrencyPolicy != "replace" { + return tasks, fmt.Errorf("Invalid cron concurrency policy for app %s (schedule %s): %s", appName, c.Schedule, c.ConcurrencyPolicy) + } tasks = append(tasks, CronTask{ App: appName, Command: c.Command, Schedule: c.Schedule, ID: cronID, + ConcurrencyPolicy: c.ConcurrencyPolicy, Maintenance: isAppCronInMaintenance || maintenance, AppInMaintenance: isAppCronInMaintenance, TaskInMaintenance: maintenance,