Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

action sandbox elides empty directories from tree artifacts #14094

Closed
ghost opened this issue Oct 8, 2021 · 6 comments
Closed

action sandbox elides empty directories from tree artifacts #14094

ghost opened this issue Oct 8, 2021 · 6 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Local-Exec Issues and PRs for the Execution (Local) team type: bug

Comments

@ghost
Copy link

ghost commented Oct 8, 2021

Description of the problem / feature request:

I happened upon a tree artifact edge case involving empty directories.

Consider two tree artifacts, treeA and treeB. Both contain an empty directory named empty, but treeB also contains a file named dummy.

$ tree tree*
treeA
└── empty
treeB
├── dummy
└── empty

When these tree artifacts are provided as inputs to a sandboxed action, Bazel elides the empty directory from treeB. If, however, a tree artifact's only content is an empty directory, then the empty directory appears in the action's sandbox. A find -L . in a genrule having both treeA and treeB reports the following to stdout:

.
./external
./external/bazel_tools
./external/bazel_tools/tools
./external/bazel_tools/tools/genrule
./external/bazel_tools/tools/genrule/genrule-setup.sh
./bazel-out
./bazel-out/k8-fastbuild
./bazel-out/k8-fastbuild/bin
./bazel-out/k8-fastbuild/bin/treeA
./bazel-out/k8-fastbuild/bin/treeA/empty
./bazel-out/k8-fastbuild/bin/treeB
./bazel-out/k8-fastbuild/bin/treeB/dummyfile

(Observe that treeB/empty is missing.)

Motivation

I'm trying to implement pkg_tree in rules_pkg (bazelbuild/rules_pkg#388) but my test cases fail because something in spawn/sandbox-land is eating my empty input directories.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

See repro at https://github.com/beasleyr-vmw/repro-treeartifact-emptysubdir

What operating system are you running Bazel on?

CentOS 8

What's the output of bazel info release?

release 4.2.1

If bazel info release returns "development version" or "(@Non-Git)", tell us how you built Bazel.

n/a

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

n/a

Have you found anything relevant by searching the web?

The following appear to be somewhat related.

Any other information, logs, or outputs that you want to share?

@aiuto aiuto added team-Core Skyframe, bazel query, BEP, options parsing, bazelrc untriaged team-Local-Exec Issues and PRs for the Execution (Local) team and removed team-Core Skyframe, bazel query, BEP, options parsing, bazelrc labels Oct 11, 2021
@meisterT
Copy link
Member

cc @larsrc-google

@larsrc-google
Copy link
Contributor

@alexjski What is the proper behaviour for tree artifacts wrt empty directories?

@alexjski
Copy link
Contributor

alexjski commented Nov 22, 2021

@alexjski What is the proper behaviour for tree artifacts wrt empty directories?

This is not at all an issue of the sandbox -- tree artifact values currently do not collect empty directories. The difference between a local build and a sandboxed one is that a local one would pick up those directories which are not represented in the metadata held by Bazel (as such it's kind of like picking up auxiliary files).

I think a workaround you could apply would be to declare those empty directories as nested tree artifacts, generated by the same action:

outer = ctx.actions.declare_directory("dir")
empty = ctx.actions.declare_directory("dir/empty")
...
ctx.actions.run(..., outputs=[outer, empty, ...], ...)

@coeuvre Do we get empty directories within tree artifacts when we run an action generating trees in RBE?

@coeuvre
Copy link
Member

coeuvre commented Dec 2, 2021

Sorry I missed the notification. For remote execution, only files are downloaded, empty directories are not downloaded.

@meisterT meisterT added P3 We're not considering working on this, but happy to review a PR. (No assignee) type: bug and removed untriaged labels Dec 15, 2021
@github-actions
Copy link

github-actions bot commented Jun 9, 2023

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jun 9, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Local-Exec Issues and PRs for the Execution (Local) team type: bug
Projects
None yet
Development

No branches or pull requests

5 participants