Repository navigation
Description
Feature Request
What challenge are you facing?
We're running into an issue where our node_modules cache has become corrupted somehow, giving us errors like:
Error: node_modules/@angular/flex-layout/media-query/breakpoints/break-points.d.ts(8,10): error TS2305: Module '"/tmp/build/faf44d05/ui/node_modules/@angular/core/core"' has no exported member 'OpaqueToken'.
on doing an ng build.
Our task configuration is like so:
---
platform: linux
inputs:
- name: ui
run:
path: ui/ci/tasks/build-ui.sh
caches:
- path: ui/node_modules
outputs:
- name: artifactsThe easiest solution for this is to nuke the node_modules directory and recreate it. As it stands, the only options for that are (a) remove the caches block from the task, (b) re-create the worker(s), (c) rename the task, or (d) modify the script to execute rm -Rf ui/node_modules/*.
As we don't have BOSH access to Concourse (only Fly), (b) is out. Since we do want caching (a) isn't really on the table. This leaves (c) and (d), both of which feel like somewhat hacky work-arounds to the issue.
A Modest Proposal
I'd like to be able to do something along the lines of fly -t target clear-cache -j pipeline/job -a task_name -c path/to/cache, which would remove all data in the cache, and present a fresh, squeaky-clean directory the next time the task runs.
Some edge cases:
- What happens if task is running when we clear the cache?
- Will this become horrifically slow if I have a large number of workers?
Activity
codesuki commentedon Nov 22, 2017
Agreed, this is something I wanted, too. Additionally it would be cool define a key for the cache by ourselves. My use case for this is, I am building and testing with bazel. My first step runs
bazel testand of course builds things, and my second step doesbazel build, but cannot re-use the cache frombazel test.vito commentedon Jan 24, 2018
Just ran into this today. Go's pretty bad a noticing
pkghas outdated bits, and the only recourse is to disable the task cache.[-]Unable to delete/clear task caches[/-][+]Delete/clear task caches[/+]alvaropinot commentedon Mar 2, 2018
I think it could also be great to have a "clean cache when build fails" feature that could be setup as part of the yml key, something like:
or even go into a failsafe strategy when a build has failed and clean the cache and retry.
Any thoughts?
ghostsquad commentedon Mar 4, 2018
CircleCI has actually a really nice way of handling this. They let you name the cache, and thus you can create more and more specific caches.
https://circleci.com/docs/2.0/caching/
bump aws-sdk-go atc
vito commentedon Jul 24, 2018
Some guidance on this, in case someone wants to submit a PR: I think this just comes down to deleting from the
worker_task_cachestable.This could hit an API endpoint like so:
This would simply translate to:
The path could be optional, since it could be annoying to have to type that out.
The net effect of this: existing cache volumes will eventually be garbage collected, as their "owner" (the task cache) will have gone away, leaving them orphaned (all owner references will be
NULL). No volumes will be killed while their build is running; there should be other safeguards for that. So I think this is actually really straightforward - just need an API endpoint andflycommand!Add API to support clearing of task caches from fly. Supports
Add API to support clearing of task caches from fly. Supports
Add API to support clearing of task caches from fly. Supports
Add API to support clearing of task caches from fly. Supports
bump etree tsa handlers mux clockwork goxmldsig genproto grpc
Add API to support clearing of task caches from fly. Supports
Add API to support clearing of task caches from fly. Supports
bump atc fly go-concourse
vito commentedon Sep 17, 2018
This was PR'ed in to v4.1.0. Thanks @edtan!