Skip to content

fix: stage apko cache as a tree artifact (follow-up to #294)#302

Merged
xnox merged 1 commit into
chainguard-dev:mainfrom
tiborv:fix/bb-rbe-output-validation-setup-script
Apr 27, 2026
Merged

fix: stage apko cache as a tree artifact (follow-up to #294)#302
xnox merged 1 commit into
chainguard-dev:mainfrom
tiborv:fix/bb-rbe-output-validation-setup-script

Conversation

@tiborv

@tiborv tiborv commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

After some more testing we noticed that the per-file cp staging introduced in #294 - which replaced ctx.actions.symlink to fix Bazel 9 sandbox issues - regresses on remote execution.

apko's cache is URL-keyed, so when a cached resource's URL ends in its own filename - typical for keyrings, e.g.

https://packages.wolfi.dev/os/wolfi-signing.rsa.pub

the cache key equals the filename and the entry lands at:

.../wolfi-signing.rsa.pub/wolfi-signing.rsa.pub

Some remote-execution backends reject declared output paths whose basename equals their parent directory name as REv2 validation failures, so cache staging fails on RBE even though the cp command itself succeeds.

Declare the whole cache as a single tree artifact (via ctx.actions.declare_directory) and populate it in one ctx.actions.run_shell. apko sees the identical files at the identical relative paths, but the problematic paths are now contents of the tree artifact rather than individually declared outputs, so per-output validation no longer sees them.

copy_to_workdir grows a list-of-Files branch for this; the lockfile, config, and apko binary continue through the existing single-file and directory paths unchanged.

…#294)

After some more testing we noticed that the per-file cp staging
introduced in chainguard-dev#294 - which replaced ctx.actions.symlink to fix
Bazel 9 sandbox issues - regresses on remote execution.

apko's cache is URL-keyed, so when a cached resource's URL ends in
its own filename - typical for keyrings, e.g.

    https://packages.wolfi.dev/os/wolfi-signing.rsa.pub

the cache key equals the filename and the entry lands at:

    .../wolfi-signing.rsa.pub/wolfi-signing.rsa.pub

Some remote-execution backends reject declared output paths whose
basename equals their parent directory name as REv2 validation
failures, so cache staging fails on RBE even though the cp command
itself succeeds.

Declare the whole cache as a single tree artifact (via
ctx.actions.declare_directory) and populate it in one
ctx.actions.run_shell. apko sees the identical files at the
identical relative paths, but the problematic paths are now contents
of the tree artifact rather than individually declared outputs, so
per-output validation no longer sees them.

copy_to_workdir grows a list-of-Files branch for this; the lockfile,
config, and apko binary continue through the existing single-file
and directory paths unchanged.
@tiborv
tiborv force-pushed the fix/bb-rbe-output-validation-setup-script branch from f3404d6 to 34ed4c6 Compare April 27, 2026 20:47

@xnox xnox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack! thank you!

note I only use apko locally, or via terraform provider apko, and never with remote executors.

It would be interesting how to setup remote executors in github actiona for testing. Do I need to sign up for some service, or can this be mocked with docker or some such?

as ideally all the issues you are seeing should be tested in our CI.

@xnox
xnox merged commit 6eba79f into chainguard-dev:main Apr 27, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants