Commit Graph

27 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
96d726c43c 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.
2026-08-12 13:11:34 -04:00
Jose Diaz-Gonzalez
cd1089500b feat: translate docker-options --sysctl on the k3s scheduler
The `docker-local` scheduler supports `--sysctl` for free because docker options are passed verbatim to `docker run`, but the k3s scheduler silently dropped it. Namespaced sysctls now render into the pod's `securityContext.sysctls` for deployments, cron jobs, and one-off runs. A sysctl the kernel does not namespace fails the deploy instead of being dropped, since it cannot take effect within a pod regardless of what was requested.
2026-08-07 05:43:00 -04:00
Jose Diaz-Gonzalez
bf2cfe1886 fix: hash scheduler-k3s cron-id label to fit Kubernetes' 63-byte cap
The `dokku.com/cron-id` label could exceed Kubernetes' 63-byte cap because the cron ID is `base36(appName === command === schedule)`, which expands roughly 1.5x per byte. The label is now keyed `dokku.com/cron-hash` and holds the `sha1` hex digest of the cron-id, a fixed 40-character value that always fits the cap. The same hex digest is mirrored into the `dokku.com/cron-hash` annotation, and the original base36 cron-id stays in the `dokku.com/cron-id` annotation that `cron:list` reads when surfacing user-facing IDs. Per-task lookups stay server-side via label selectors, so `cron:set --maintenance` and the forbid/replace concurrency checks on `dokku run --cron-id` keep working without any in-memory filtering.
2026-05-24 16:52:22 -04:00
Jose Diaz-Gonzalez
b66df28d96 fix: harden scheduler-k3s cron manifests and dockerfile run startup
The cron-id label could exceed Kubernetes' 63-byte cap when commands or
schedules were long, and an all-digit job-suffix or cron-id rendered as
an unquoted YAML scalar caused the API server to reject manifests. Run
pods built from dockerfiles also occasionally hit the 10s startup wait
on a cold image pull, even though the pod was scheduled correctly.

The cron-id is now stored as an annotation and a shorter hash is used as
the selector label. Every interpolated annotation and label value in the
cron-job and deployment templates is now quoted to prevent numeric
coercion, and the run-pod wait timeout is raised to 30 seconds.
2026-05-11 14:49:58 -04:00
Jose Diaz-Gonzalez
3a845f4d14 fix: route CNB images through launcher on scheduler-k3s
Mirror the docker-local fix in #8525 for the k3s scheduler. CNB images default to a `/cnb/process/web` entrypoint that ignores incoming args, so non-web deployments, scheduled cron jobs, and ad-hoc `dokku run` / `cron:run` commands all need an explicit `launcher` entrypoint. The deployment and cron-job helm templates now set `command: [launcher]` when `image.type` is `pack`, and `TriggerSchedulerRun` sets the entrypoint to `launcher` for pack images while finishing the previously stubbed Procfile lookup branch so the resolved command is actually scheduled.
2026-05-11 02:05:56 -04:00
Jose Diaz-Gonzalez
cfb7da8ec0 feat: scheduler-k3s renders pvc-backed volumes from storage attachments
Adds a per-entry storage helm chart that owns the PVC and (when host_path is set) the PV, and three triggers for the storage plugin to drive: storage-create installs/upgrades the chart with storage-class existence validation, storage-destroy uninstalls it, storage-status reports the PVC phase. App deployment and cron-job charts now consume storage-app-mounts and reference each PVC by name; the // todo: implement volumes blocks are gone. ProcessVolume gained sub_path, read_only, and persistent_claim fields and the deployment/cron-job templates render them.
2026-04-29 14:49:15 -04:00
Jose Diaz-Gonzalez
ef9bdc0379 fix: split env config and image pull secret into separate helm releases
Bundling these Secrets in the app helm chart caused two bugs in the scheduler-k3s plugin: a chart rollback could delete Secrets that older ReplicaSets still referenced by exact timestamped name (`env-{app}.{ts}` and `ims-{app}.{ts}`), hard-crashing pods until manual intervention; and the strategic-merge `patchMergeKey` on `imagePullSecrets` let stale entries leak into the live Deployment until the list pointed at many nonexistent Secrets. Each Secret now lives in its own helm release with a stable name (`config-{app}` and `pull-secret-{app}`), installed before the app chart on every deploy. The deployment trigger also prunes any leaked `imagePullSecrets` entries from the live Deployment so the next deploy lands on a clean list, and the rename and destroy paths uninstall the new releases (and the previously-leaked TLS release on rename) under the old app name.
2026-04-29 12:18:03 -04:00
Jose Diaz-Gonzalez
a6d65c821f feat: implement cron and one-off run task TTLs
Closes #7938
2025-11-18 16:46:31 -05:00
Jose Diaz-Gonzalez
f38bc64119 feat: expose concurrency policy to kubernetes jobs 2025-11-10 03:07:29 -05:00
Jose Diaz-Gonzalez
c885205b91 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.
2025-11-09 23:16:38 -05:00
Jose Diaz-Gonzalez
a1b6d05568 fix: correct template 2025-09-12 19:19:04 -04:00
Jose Diaz-Gonzalez
f90a4061c0 feat: create SecurityContext for k3s scheduler from docker-options
Closes #7664
2025-09-12 18:09:33 -04:00
Jose Diaz-Gonzalez
0a3f7262a4 chore: move comment around 2025-08-22 02:30:19 -04:00
Jose Diaz-Gonzalez
1b95e01ea3 fix: move range 2025-07-04 04:24:09 -04:00
Jose Diaz-Gonzalez
6da9be2d65 refactor: use chart values directly instead of attempting to template out cron-job and keda files 2025-07-04 04:24:09 -04:00
Jose Diaz-Gonzalez
fd2cfe8080 fix: correctly pull the deployment id from an app's helm values when executing dokku run under the k3s scheduler
- Fix the internal identifier of deployment_id -> deployment_id
- Add tests for both enter and run.
2024-11-04 14:44:25 -05:00
Jose Diaz-Gonzalez
7a5bd7ee0f refactor: use a helper function for printing out both labels and annotations 2024-03-01 17:42:24 -05:00
Jose Diaz-Gonzalez
1ae2df52f5 fix: use image pull secrets instead of registries.yaml to reference private repositories
While this will now more or less require a local docker login - which can be overridden by setting the image-pull-secrets property - this ensures every deploy has a valid context.

One annoying thing is that the secret is per-app vs global, meaning that if the secret must be rotated, all apps need to be redeployed. A future change can fix that by deploying a global secret, or if folks really desire, this can be done by setting the image-pull-secrets property on the app/globally.
2024-02-12 17:15:37 -05:00
Jose Diaz-Gonzalez
f5f583b12b feat: add support for specifying annotations
As the command contains a colon, it must be handled in the commands binary as opposed to subcommands.

Also include a simple bats test.
2024-02-06 13:54:53 -05:00
Jose Diaz-Gonzalez
d7ff8552d1 fix: index the process map to ensure the correct config is pulled
Without this change, certain generated process names - like those for a cron job - may be incorrectly handled when indexing the process map.
2024-02-06 04:41:14 -05:00
Jose Diaz-Gonzalez
6625846ecc Merge pull request #6555 from dokku/service-account
Add support for app-specific service accounts when deploying via k3s
2024-02-05 17:18:20 -05:00
Jose Diaz-Gonzalez
238535be0c fix: respect the release namespace when creating resources for a k3s deploy 2024-02-05 16:50:00 -05:00
Jose Diaz-Gonzalez
d02c04c2a5 feat: add support for app-specific service accounts when deploying via k3s
Service accounts must still be bound to a role, but this ensures apps do not get access to the default service account.
2024-02-05 16:47:57 -05:00
Jose Diaz-Gonzalez
c1b3c73096 chore: drop unnecessary key 2024-01-23 09:32:41 -05:00
Jose Diaz-Gonzalez
1d07801f3c fix: set ttl property at correct level for cronjobs 2024-01-23 07:25:51 -05:00
Jose Diaz-Gonzalez
a0811c2cb3 fix: move field to correct location 2024-01-23 04:42:20 -05:00
Jose Diaz-Gonzalez
2336063ca2 refactor: move templating into pseudo-generated helm chart
The previous mechanism of constructing the helm chart was pretty obnoxious due to needing to have some things in the object and some in template files that were appended afterwards. This change simplifies that by using template files per type with minimal replacements.
2024-01-23 03:00:27 -05:00