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

Skip empty directories instead of throwing in prefetcher. #17183

Closed
wants to merge 1 commit into from

Conversation

tjgq
Copy link
Contributor

@tjgq tjgq commented Jan 10, 2023

While non-empty tree artifacts in the inputs to an action are expanded into the files they contain and omitted from the input mapping, empty tree artifacts are still present, as they signal the need to create the directory. Thus, the check added in 763f966 is incorrect.

I'm explicitly skipping the empty tree artifacts in prefetchFiles() as otherwise they get skipped as a result of FileArtifactValue#isRemote() returning false for the FileArtifactValue associated with an empty tree artifact (even if it was produced remotely!), which is extremely subtle.

@tjgq tjgq force-pushed the emptytree branch 2 times, most recently from a6ab26f to 4a9b6a0 Compare January 10, 2023 17:40
While non-empty tree artifacts in the inputs to an action are expanded into
the files they contain and omitted from the input mapping, empty tree
artifacts are still present, as they signal the need to create the directory.
Thus, the check added in 763f966 is incorrect.

I'm explicitly skipping the empty tree artifacts in prefetchFiles() as
otherwise they get skipped as a result of FileArtifactValue#isRemote()
returning false for the FileArtifactValue associated with an empty tree
artifact (even if it was produced remotely!), which is extremely subtle.
@tjgq tjgq marked this pull request as ready for review January 10, 2023 18:32
@tjgq tjgq requested a review from a team as a code owner January 10, 2023 18:32
@tjgq tjgq requested a review from coeuvre January 10, 2023 18:32
// Source artifacts don't need to be fetched.
if (input instanceof Artifact && ((Artifact) input).isSourceArtifact()) {
continue;
}

// Skip empty tree artifacts (non-empty tree artifacts should have already been expanded).
if (input.isDirectory()) {
continue;
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to check whether the directory is actually empty?

Copy link
Contributor Author

@tjgq tjgq Jan 10, 2023

Choose a reason for hiding this comment

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

Unfortunately, the FileArtifactValue returned by MetadataHandler#getMetadata for a tree artifact doesn't provide enough information to do the check in a clean way, and I'd rather not add API surface just for it.

I wonder if we could do this in a more principled way, by having the ArtifactExpander produce a special ActionInput that signals "this is root directory for an empty tree artifact"? But that's clearly for a separate PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I started working on that in https://github.com/bazelbuild/bazel/pull/16015/files. If you are also interested in this, we could continue the discussion there.

@ShreeM01 ShreeM01 added team-Remote-Exec Issues and PRs for the Execution (Remote) team awaiting-user-response Awaiting a response from the author labels Jan 10, 2023
hvadehra pushed a commit that referenced this pull request Feb 14, 2023
While non-empty tree artifacts in the inputs to an action are expanded into the files they contain and omitted from the input mapping, empty tree artifacts are still present, as they signal the need to create the directory. Thus, the check added in 763f966 is incorrect.

I'm explicitly skipping the empty tree artifacts in prefetchFiles() as otherwise they get skipped as a result of FileArtifactValue#isRemote() returning false for the FileArtifactValue associated with an empty tree artifact (even if it was produced remotely!), which is extremely subtle.

Closes #17183.

PiperOrigin-RevId: 501207095
Change-Id: Ib52727d6fdc6b7a291a61fba33914e57531fb1f4
tjgq added a commit to tjgq/bazel that referenced this pull request Mar 9, 2023
While non-empty tree artifacts in the inputs to an action are expanded into the files they contain and omitted from the input mapping, empty tree artifacts are still present, as they signal the need to create the directory.

I'm explicitly skipping the empty tree artifacts in prefetchFiles() as otherwise they get skipped as a result of FileArtifactValue#isRemote() returning false for the FileArtifactValue associated with an empty tree artifact (even if it was produced remotely!), which is extremely subtle.

Closes bazelbuild#17183.

[NOTE: this is a combined cherry pick of 763f966 and 4c57def, as the former left Bazel in a broken state.]

PiperOrigin-RevId: 501207095
Change-Id: Ib52727d6fdc6b7a291a61fba33914e57531fb1f4
ShreeM01 pushed a commit that referenced this pull request Mar 9, 2023
While non-empty tree artifacts in the inputs to an action are expanded into the files they contain and omitted from the input mapping, empty tree artifacts are still present, as they signal the need to create the directory.

I'm explicitly skipping the empty tree artifacts in prefetchFiles() as otherwise they get skipped as a result of FileArtifactValue#isRemote() returning false for the FileArtifactValue associated with an empty tree artifact (even if it was produced remotely!), which is extremely subtle.

Closes #17183.

[NOTE: this is a combined cherry pick of 763f966 and 4c57def, as the former left Bazel in a broken state.]

PiperOrigin-RevId: 501207095
Change-Id: Ib52727d6fdc6b7a291a61fba33914e57531fb1f4
@ShreeM01
Copy link
Contributor

ShreeM01 commented Mar 9, 2023

@bazel-io fork 6.2.0

ShreeM01 pushed a commit to ShreeM01/bazel that referenced this pull request Mar 9, 2023
While non-empty tree artifacts in the inputs to an action are expanded into the files they contain and omitted from the input mapping, empty tree artifacts are still present, as they signal the need to create the directory. Thus, the check added in 763f966 is incorrect.

I'm explicitly skipping the empty tree artifacts in prefetchFiles() as otherwise they get skipped as a result of FileArtifactValue#isRemote() returning false for the FileArtifactValue associated with an empty tree artifact (even if it was produced remotely!), which is extremely subtle.

Closes bazelbuild#17183.

PiperOrigin-RevId: 501207095
Change-Id: Ib52727d6fdc6b7a291a61fba33914e57531fb1f4
ShreeM01 added a commit that referenced this pull request Mar 10, 2023
While non-empty tree artifacts in the inputs to an action are expanded into the files they contain and omitted from the input mapping, empty tree artifacts are still present, as they signal the need to create the directory. Thus, the check added in 763f966 is incorrect.

I'm explicitly skipping the empty tree artifacts in prefetchFiles() as otherwise they get skipped as a result of FileArtifactValue#isRemote() returning false for the FileArtifactValue associated with an empty tree artifact (even if it was produced remotely!), which is extremely subtle.

Closes #17183.

PiperOrigin-RevId: 501207095
Change-Id: Ib52727d6fdc6b7a291a61fba33914e57531fb1f4

Co-authored-by: Tiago Quelhas <[email protected]>
@tjgq tjgq deleted the emptytree branch March 7, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-user-response Awaiting a response from the author team-Remote-Exec Issues and PRs for the Execution (Remote) team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants