fix: retire cron containers past their active deadline

Cron containers were never reaped once they exceeded their active deadline, so a hung cron task ran indefinitely instead of being retired after 24 hours as documented. `cron:run` now also accepts a `--ttl-seconds` argument, matching the one `dokku run` already takes.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-08-12 13:11:34 -04:00
1 parent 0bfd35dada
commit 96d726c43c
18 files changed
+1170 -906

No files matched your search

+17
View File
@@ -42,6 +42,23 @@ var (
const MaintenancePropertyPrefix = "maintenance."
// DefaultTTLSeconds is how long a cron task may run before it is reaped. The
// docker-local scheduler stamps this onto the container as the
// com.dokku.active-deadline-seconds label, while the k3s scheduler renders it
// as the CronJob's activeDeadlineSeconds.
const DefaultTTLSeconds int64 = 86400
// validateTTLSeconds returns an error if the requested task lifetime is not a
// positive number of seconds. A zero or negative deadline would either expire
// the task the instant it starts or never expire it at all.
func validateTTLSeconds(ttlSeconds int64) error {
if ttlSeconds <= 0 {
return fmt.Errorf("--ttl-seconds must be a positive integer")
}
return nil
}
// CronTask is a struct that represents a cron task
type CronTask struct {
// ID is a unique identifier for the cron task