Commit Graph

31 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
c6b4ea75c1 refactor: move host-crontab generation into cron plugin
Host-crontab generation for `app.json` cron tasks now lives in the `cron` plugin, gated by a new `scheduler-uses-host-cron` trigger that the `docker-local` scheduler answers true while self-managed schedulers such as `k3s` answer false. This lets any host-cron scheduler participate in normal `app.json` cron without coupling to `scheduler-docker-local` or duplicating the crontab writer, while the `k3s` scheduler continues to manage its own in-cluster cron jobs.

Closes #8862.
2026-07-22 08:35:11 -04:00
Jose Diaz-Gonzalez
3bf6c72451 fix: align Go-plugin :report JSON keys with bash-strip convention
Every Go-implemented plugin's `:report --format json` now emits keys without the redundant `<plugin>-` head segment, matching the shape bash plugins have always emitted. The CLI flag names and `:set` semantics are unchanged. For backwards compatibility during the 0.38.x patch series, the legacy `<plugin>-<property>` keys are emitted side-by-side with the new keys, and a future major release will drop the legacy keys. `common.ReportSingleApp` is refactored to accept a `ReportSingleAppInput` struct with a `Validate()` method so the input is checked before any work runs, which also catches the latent `"docker options"` reportType bug at the API boundary.
2026-05-27 07:17:00 -04:00
Jose Diaz-Gonzalez
3feedd8786 fix: align ps/cron :report --global keys with plugin convention
The `ps` and `cron` plugins emitted `:report --format json` keys that
skipped the `<plugin>-` prefix or `-global-` infix used by every other
plugin, forcing external consumers to special-case those names. Rename
the affected report flags so they match the `<plugin>-global-<property>`
and `<plugin>-computed-<property>` convention introduced in 0.38.0, and
add the previously missing `computed-` siblings to both the per-app and
`--global` reports so the shape lines up with caddy, haproxy, and
traefik.
2026-05-26 20:33:32 -04:00
Jose Diaz-Gonzalez
ac95225809 fix: prevent host shell injection from app.json cron commands
The docker-local scheduler wrote each app.json cron command verbatim into the dokku user's crontab, where cron's `bash -c` interpreted any shell metacharacters in the command on the host as the dokku user rather than inside the container. The crontab line is now `dokku cron:run <app> <cron-id>`, and the command is resolved from app.json and exec'd inside the container at run time. Commands containing shell operators are also rejected when app.json is validated at deploy time.
2026-05-25 02:14:21 -04:00
Jose Diaz-Gonzalez
357e12bd83 refactor: rename computed-* helpers, expose computed vector and network keys
Addresses review feedback on #8640. fn-archive-max-size,
fn-archive-max-files, fn-git-deploy-branch, and fn-git-keep-git-dir are
renamed with `computed` in the function name so the names match the
resolved-with-default semantic they implement, and every caller is
updated in lockstep. logs:report renames the misordered
--logs-vector-global-image and --logs-vector-global-networks to
--logs-global-vector-image and --logs-global-vector-networks, makes the
global getters return the raw stored value, and adds
--logs-computed-vector-image, --logs-computed-vector-networks, and
--logs-computed-vector-sink. network:report --global gains the
computed-* keys for attach-post-create, attach-post-deploy,
initial-network, and tld so external tooling can read the resolved
value at global scope. The --quiet flag is dropped from every
:report --format json | jq invocation across the PR's bats files; the
report's --format json output is the only stdout and the flag is
redundant.
2026-05-23 04:47:03 -04:00
Jose Diaz-Gonzalez
82d1f8e11c test: align triplet tests with actual plugin behavior
Fixes CI failures from the prior commit's bats additions.
storage report mounts are prefixed with `-v `, logs.bats setup does not
auto-create the test app, the nginx-vhosts shell report emits JSON keys
without the `nginx-` plugin prefix, registry computed-image-repo falls
back to the default `dokku/<app>` repo name when no template is set,
cron computed-maintenance follows OR-not-override semantics so a per-app
`false` does not override a global `true`, the scheduler subcommand
help string is `Manage scheduler settings`, and bringing ps procfile-path
into the #8640 raw convention required updating the pre-existing
`(ps:set) procfile` assertion. Also extends fn-git-keep-git-dir to fall
back through the global property before the built-in default so global
keep-git-dir actually takes effect at deploy time.
2026-05-23 01:35:04 -04:00
Jose Diaz-Gonzalez
cdcf1fc669 test: backfill raw/global/computed report triplet coverage across plugins
The bats coverage for plugin :report keys has been uneven since the raw/global/computed split landed in PR #8640. This commit adds a single combined triplet test per settable property across app-json, builder, builder-dockerfile, builder-herokuish, builder-lambda, builder-nixpacks, builder-pack, builder-railpack, buildpacks, cron (maintenance), git (keep-git-dir, rev-env-var, source-image), logs (vector-sink, vector-global-image, vector-global-networks), network (attach-post-create, attach-post-deploy, initial-network), proxy (per-app type), ps (stop-timeout-seconds), registry (image-repo, push-on-release, push-extra-tags), storage (build/deploy/run mounts), and adds a new tests/unit/scheduler.bats and tests/unit/nginx-vhosts_properties.bats. Brings ps `procfile-path` and `stop-timeout-seconds` global getters in line with the #8640 convention (raw global, default resolved in computed). Documents the read-only and internal properties that surface in `:report` (or are written by Dokku) but cannot be managed by `:set` in a new `## Internal properties` section appended to each affected plugin's docs page.
2026-05-23 00:05:33 -04:00
Jose Diaz-Gonzalez
4001f318a6 fix: support --global on cron:set
`cron:set --global` wrote the property but emitted `unknown flag: --global` because the post-set `scheduler-cron-write` trigger received `--global` as the appName arg, which pflag rejected before reaching the trigger body.

The trigger args now omit appName for global writes, and the `scheduler-k3s` cron-write trigger short-circuits when called without an app since per-app reconciliation requires a real app name. The docker-local trigger already regenerates the global crontab from all apps so global `mailfrom`/`mailto` are picked up without any further changes.
2026-05-13 12:37:14 -04:00
Jose Diaz-Gonzalez
0f78f81d71 test: drop cron:set in cron:report --global test
The set step relied on scheduler-cron-write accepting `--global` as the appName, which the scheduler-k3s plugin trigger does not.
2026-04-29 10:31:02 -04:00
Jose Diaz-Gonzalez
8282981361 feat: accept --global on :report subcommands
Every `:report` subcommand now recognizes `--global` as a scope selector that limits the report to globally-configured properties, including in JSON form via `--global --format json`. Previously this combination was rejected because `--global` was treated as an info flag, conflicting with `--format`. The shared `common.ParseReportArgs` helper now returns a `ReportArgs` struct exposing the parsed scope; each Go and bash report selects a global-only flag map when scope is global, and skips per-app verification.
2026-04-29 10:30:59 -04:00
Jose Diaz-Gonzalez
c6bd80aca6 tests: update tests 2025-11-13 01:55:32 -05:00
Jose Diaz-Gonzalez
3162fa5b9a debug: run sleep for longer and check the inspect output of the cron container 2025-11-10 18:02:46 -05:00
Jose Diaz-Gonzalez
c95cb526be fix: correct lint issue 2025-11-10 03:11:11 -05:00
Corey Taylor
983115c827 Add test for cron concurrency policy 2025-11-10 03:11:08 -05:00
Jose Diaz-Gonzalez
b8f32f6ea4 tests: add concurrency_policy to test check 2025-11-10 03:08:03 -05:00
Jose Diaz-Gonzalez
8ba6ce94fc test: add tests for cron suspend and resume commands 2025-11-10 02:00:14 -05:00
Jose Diaz-Gonzalez
00ce3932d0 fix: update the json output 2025-11-09 23:16:38 -05:00
Jose Diaz-Gonzalez
7adeee7086 feat: add ability to list global cron tasks
Closes #7732
2025-09-14 04:38:19 -04:00
Jose Diaz-Gonzalez
398a78b2f6 refactor: move cron-write to scheduler-cron-write 2025-06-10 21:45:08 -04:00
Jose Diaz-Gonzalez
ce1c7543d2 fix: correct issues in tests referencing now missing python binary 2024-09-21 17:20:20 -04:00
Jose Diaz-Gonzalez
9fca7cf7d7 tests: fix test for new behavior 2024-03-06 10:58:29 -05:00
Jose Diaz-Gonzalez
5846301a48 tests: make it possible to specify an alternative base domain for tests
When developing Dokku, it is useful to use a real domain to test actual functionality. This is impossible if the domain is hardcoded to dokku.me in testing.
2023-08-05 20:58:26 -04:00
Jose Diaz-Gonzalez
515994c8d3 feat: add the ability to execute a cron task on the fly
Closes #4904
2023-08-05 10:58:57 -04:00
Jose Diaz-Gonzalez
820883e60c feat: add json format output to cron:list command
This makes it easier to parse output in a machine-readable format - such as when interacting with cron tasks via jq for writing tests.
2023-08-05 10:58:57 -04:00
Jose Diaz-Gonzalez
9d332e9b2d chore: run shfmt against all test files 2022-07-21 14:57:42 -04:00
Jose Diaz-Gonzalez
257baa1d46 refactor: run crontab under sudo to support rhel systems
RHEL blocks users from executing crontab as themselves Because Of Reasons so we need to use sudo instead.

Also refactors file writing to properly support writing the permissions on sudoers files going forward.

Closes #5020
2022-02-27 19:17:04 -05:00
Jose Diaz-Gonzalez
065f5e5922 fix: do not inject max-size option when not using local or json-file log drivers
Closes #4376
2021-02-07 22:10:06 -05:00
Jose Diaz-Gonzalez
be84325de1 feat: add support for injected cron entries
This allows alternative plugins - such as dokku-letsencrypt - to inject scheduled cron tasks into the cron system used by Dokku. Cron systems can choose to include or not include a cron task based on the specified scheduler, and can also optionally use a third parameter to store arbitrary information.
2021-02-07 16:45:34 -05:00
Jose Diaz-Gonzalez
8efac2923b tests: split tests up 2021-01-21 00:22:49 -05:00
Jose Diaz-Gonzalez
0bd7613da4 tests: add test for creation of crontab file 2021-01-20 15:45:48 -05:00
Jose Diaz-Gonzalez
f7ef14d737 feat: add initial scheduled task implementation
This functionality enables users to manage a global crontab for the Dokku user that contains all scheduled tasks across all apps. Alternative schedulers can implement cron tasks as desired.
2021-01-20 14:49:48 -05:00