bug: actions/cache has inconsistent behavior in LXC and Docker containers. #918
Labels
No labels
FreeBSD
Kind/Breaking
Kind/Bug
Kind/Chore
Kind/DependencyUpdate
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
Windows
linux-powerpc64le
linux-riscv64
linux-s390x
run-end-to-end-tests
run-forgejo-tests
run-multi-platform-tests
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
forgejo/runner#918
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Can you reproduce the bug on the Forgejo test instance?
No
Description
This is an extension of issue #916
I ran the following workflow twice and the LXC container always runs with
Cache not found for input keys: lxc-cache, but if I remove the${{ forge.workspace }}/from thepathparameter, it works fine.either way, after the workflow execution is complete, I see the message in the output that the cache was saved.
my runner config:
Forgejo Version
12.0.1+gitea-1.22.0
Runner Version
9.1.1
How are you running Forgejo?
Docker
How are you running the Runner?
Debian Bookworm on QEMU VM
Logs
No response
Workflow file
Could you please attach the logs?
This is a good reproducer, I'll try that today.
I copy/pasted the workflow verbatim. With a runner 9.1.1 installed from binary with the following config, it works for me 🤔
https://v13.next.forgejo.org/earl-warren/lxc-cache/actions/runs/1/jobs/1
The second time the workflow is running, LXC still has no cache found.
Is the same result of your test?
My previous wording may not have been very clear. If the workflow is run twice, the Docker container can restore the cache on the second run, but the LXC container always outputs "cache not found."
I get it now.
First run
https://v13.next.forgejo.org/earl-warren/lxc-cache/actions/runs/1/jobs/1
Both Docker & LXC populate the cache
Second run
Docker retrieves the cache successfully
LXC does not retrieve the cache successfully
With this workflow (i.e.
path: cacheinstead ofpath: ${{ forge.workspace }}/cache)First run
Populates the cache
https://v13.next.forgejo.org/earl-warren/lxc-cache/actions/runs/3
Second run
Restores the cache
https://v13.next.forgejo.org/earl-warren/lxc-cache/actions/runs/4
@Hill-98 it is perfectly reproducible now 👍
There is no guarantee that
${{ forge.workspace }}is a constant. It turns out to be for Docker/podman based jobs (e.g./workspace/earl-warren/lxc-cache). But for LXC based jobs it contains a random path component (e.g./home/earl-warren/.cache/act/9dc369b9a28961d6/hostexecutorwhere9dc369b9a28961d6is the random part).This is why the second run cannot retrieve the cache from the previous run: they both have different paths. And also the reason why it succeeds when using
cachealone, because it is the same from one run to the next.Does that clarify the issue?
I see. So would changing
actions/cacheor the cache server fix this?I acknowledge this is confusing (I was confused myself... ) because it is not immediately intuitive that
${{ forge.workspace }}/mydirectorymay be evaluated to a different string on each job run. It should be documented.But it does not seem like a bug to fix. You will get a consistent behavior if
path: something/I/want/to/cacheis identical across job runs.Do you see what I mean?
I see.
Do you think we should record this in the documentation?
I thought about that but...
actions/cacheis where it would belong to be discoverable. Or even as a bug report there: the root of my confusion (and yours presumably) is that I don't understand why thepathwould matter to retrieve the entry when thekeyis unambiguous. But it does, evidently.Look at: https://github.com/actions/cache#cache-version
The version of the cache used internally is related to the path, so this is expected for GitHub, but broken for Forgejo's LXC.
Good find, I missed it!
It works as expected if the path is not random.
${{ forge.workspace }}is not guaranteed to be a fixed string across all jobs. It happens to be for Docker based runs in Forgejo Actions. But it is not for LXC based runs.What is the problem with using
somethinginstead of${{ forge.workspace }}/somethingfor the path?No problem, but the absolute path is always reassuring, lol...
In my current use case, this problem no longer affects me.
I agree absolute paths are reassuring.
/opt/cachewould also do.Let's close this then.