Schedule icon
Commands icon
Process icon
Return icon
Switch icon
If icon
SlackIncomingWebhook icon
Log icon

Dagger Engine Cache Maintenance Gate

Confirm the Dagger engine is reachable, then optionally run its own local-cache prune as scheduled maintenance instead of automatic GC.

Categories
CoreInfrastructure

The Dagger engine's own garbage collector only prunes the local cache once disk usage crosses its own internal threshold, which means cache entries a team wanted to keep can disappear at an unpredictable moment chosen by disk pressure, not by policy. Running the engine's own documented prune command on a schedule, instead, puts that decision back under a team's control. This blueprint confirms the engine is actually executing containers, not just that the CLI binary is present, before deciding whether to run that maintenance step at all.

How it works

  1. probe_engine_connectivity (io.kestra.plugin.dagger.Commands) runs a trivial pipeline, container | from alpine | with-exec echo DAGGER_ENGINE_OK | stdout, with allowFailure: true so a broken install or unreachable engine does not stop the flow before it can be classified as PROBE_FAILED below.
  2. classify_engine_status (io.kestra.plugin.core.debug.Return) returns PROBE_FAILED when the probe did not return at all, HEALTHY otherwise.
  3. route_by_engine_status (io.kestra.plugin.core.flow.Switch) branches on that status. On HEALTHY, a nested io.kestra.plugin.core.flow.If runs dagger core engine local-cache prune only when auto_prune_cache is true, and a second If fails loudly to Slack if the prune itself did not complete, rather than reporting a failed prune as a success. On PROBE_FAILED, Slack is alerted instead. A defaults branch logs anything unexpected.
  4. log_audit_summary always runs last. The errors block posts to Slack if the flow itself fails outside the gate logic above.

What you get

  • A real connectivity check that the engine executes a container, not a weaker check that only confirms the CLI is installed.
  • Cache maintenance on your own schedule, not only when the engine's internal disk threshold forces it.
  • A prune failure that is reported as a failure, never silently treated as a success.

Who it's for

  • Platform teams running Dagger as shared CI/CD infrastructure who want predictable cache maintenance instead of relying on the engine's own threshold-triggered GC.
  • Teams evaluating the Dagger plugin who want a working example of io.kestra.plugin.dagger.Commands beyond a single one-off pipeline call.

Why orchestrate this with Kestra

Dagger's engine has no scheduler of its own, cache maintenance either happens automatically at a disk-pressure threshold or has to be triggered by hand. Kestra adds the schedule, the pre-check that the engine is actually healthy first, and the Slack alert on either a connectivity or a prune failure, as one declarative, auditable flow.

Prerequisites

  • A worker able to run the io.kestra.plugin.core.runner.Process task runner, with network access to install the pinned Dagger CLI if not already present, and a reachable Dagger engine, either local (Docker Desktop style) or remote.
  • For local testing, Dagger's own official quickstart, which runs an engine inside Docker automatically the first time any dagger command executes, no separate engine container needs to be started by hand.
  • A Slack incoming webhook for alerts.

Secrets

  • SLACK_WEBHOOK: Slack incoming webhook URL used by the alert tasks and the errors block.

    In Kestra OSS, set this as a base64-encoded environment variable, for example SECRET_SLACK_WEBHOOK.

Quick start

  1. Install Docker and the Dagger CLI is auto-installed by the task itself on first run.
  2. Add the SLACK_WEBHOOK secret.
  3. Run this flow manually with the defaults, it should report HEALTHY and take no maintenance action since auto_prune_cache defaults to false.
  4. Run it again with auto_prune_cache: true, it should report the prune completing on the already-confirmed-healthy engine.
  5. Enable the every_night trigger.

How to extend

  • Parse dagger core engine local-cache entry-set for real cache size and entry count once you have confirmed its exact output format against your own installed Dagger version, this blueprint deliberately does not parse that output since the exact field names were not confirmed against primary documentation at build time.
  • Add --use-default-policy or an explicit space-threshold flag to local-cache prune, once confirmed against your installed version's own --help output, to prune to a specific target rather than the command's own default behavior.
  • Chain a second pipeline after a healthy probe that actually builds your real project, turning this into a pre-flight check before a CI run rather than a synthetic probe.

Pitfalls

  • This blueprint deliberately does not parse local-cache entry-set for a cache size or entry count, I could not confirm its exact JSON or table output shape against primary Dagger documentation, only secondary sources, so no threshold-based classification is built on top of it. See How to extend before relying on that data.
  • probe_engine_connectivity only confirms the engine executed one Alpine container successfully, not that a real, larger pipeline using your own images and registries will also succeed.
  • Running local-cache prune removes cache entries. On a shared engine serving several pipelines, this can increase build time for whichever pipeline runs next and has to rebuild from a cold cache, time this trigger for a genuinely idle window.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.