Skip to content

Add TTL/expiry for task caches and CONCOURSE_DEFAULT_TASK_CACHE_TTL - #9533

Merged
taylorsilva merged 2 commits into
masterfrom
task-cache-ttl
Apr 20, 2026
Merged

taylorsilva merged 2 commits into
masterfrom
task-cache-ttl

Conversation

@taylorsilva

Copy link
Copy Markdown
Member

Changes proposed by this PR

This PR adds a ttl param to the task.caches object and a web node flag CONCOURSE_DEFAULT_TASK_CACHE_TTL which defaults to a value of 0s (no expiry).

Task caches currently only expire if a pipeline or job is paused/archived/deleted. For an active pipeline/job with task caches, the caches will grow forever and never be GC'd. This can result in worker disks slowly filling up over several days or weeks unless the cache user takes deliberate steps to manage their task cache.

When upgrading to a version with this feature all existing task caches will receive a TTL of 0 (no expiry). If a default TTL is set, as task caches are used, their TTL will be updated to the default or the one configured in the task. The task-level configuration takes precedence over the web-node level setting.

Example pipeline:

jobs:
- name: job
  plan:
  - task: cache
    config:
      platform: linux
      image_resource:
        type: mock
        source: {mirror_self: true}
      caches:
        - path: /cache/never-expires
        - path: /cache/expires
          ttl: 1m

      run:
        path: sh
        args:
        - -exc
        - |
          echo hello

- ttl for task caches defaults to no expiry
- ttl must be at least 1s. Shorter intervals are not supported.
- added a global config on the web node to allow operators to set a
  default ttl for task caches

Signed-off-by: Taylor Silva <[email protected]>
@taylorsilva
taylorsilva requested a review from a team April 15, 2026 17:08
otherwise the task cache's last_used is not updated. The existing query
already takes into account that the cache may exist.

Signed-off-by: Taylor Silva <[email protected]>
@taylorsilva taylorsilva added this to the v8.2.0 milestone Apr 20, 2026
@taylorsilva

Copy link
Copy Markdown
Member Author

I've manually tested this to make sure task-level settings are respected and that the web-level default setting applies when no task-level setting is present.

@taylorsilva
taylorsilva merged commit dc1483f into master Apr 20, 2026
12 checks passed
@taylorsilva
taylorsilva deleted the task-cache-ttl branch April 20, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant