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

Prevent collisions between attempts to materialize an immutable input digest. #15652

Merged

Conversation

stuhood
Copy link
Member

@stuhood stuhood commented May 25, 2022

Fixes #13899.

[ci skip-build-wheels]

@stuhood stuhood added needs-cherrypick category:bugfix Bug fixes for released features labels May 25, 2022
@stuhood stuhood added this to the 2.11.x milestone May 25, 2022
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

😭🥳

@jyggen thank you so much for commenting that hint about remote caching

@@ -94,58 +82,21 @@ impl ImmutableInputs {
digest, e
)
})?;

let dest = chroot.path().join(digest.hash.to_hex());
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm totally lost. How is this reproducible digest suffix any more anonymous than the tmpdir its being joined with?

Copy link
Member Author

Choose a reason for hiding this comment

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

The creation of the tempdir is guaranteed not to collide (via OS facilities, presumably), so each materialization attempt is in a fresh temporary directory. The digest suffix is a convenience for readability: it's the temp dir that is avoiding collisions.

Copy link
Contributor

Choose a reason for hiding this comment

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

On the LHS:

self.store..materialize_directory(
  chroot.path().to_path_buf(),
  directory_digest,
  Permissions::ReadOnly,
)

On the RHS - paraphrasing with an inline:

self.store..materialize_directory(
  chroot.path().join(digest.hash.to_hex()),
  directory_digest,
  Permissions::ReadOnly,
)

So the only change is to use the tempdir as-is instead of renaming it to a fixed self.workdir.path().join(digest.hash.to_hex()) dest - Got it.

Why was the self.workdir rooting important before and not now? Or was it never?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so self.workdir is already a TempDir. So we create a TempDir in a TempDir, as we always did, but no longer rename from <tmpdir>/<tmpdir> -> <tmpdir>/<digest> we now just directly create <tmpdir>/<tmpdir>/<digest>. It would seem the outer could just be a normal dir now, but that's only mildly confusing as is.

Copy link
Contributor

@jsirois jsirois left a comment

Choose a reason for hiding this comment

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

Assuming self.workdir rooting of these digests was never important, LGTM.

@stuhood stuhood merged commit 770c90a into pantsbuild:main May 26, 2022
@stuhood stuhood deleted the stuhood/immutable-inputs-cancellation branch May 26, 2022 01:17
stuhood added a commit to stuhood/pants that referenced this pull request May 26, 2022
stuhood added a commit to stuhood/pants that referenced this pull request May 26, 2022
stuhood added a commit that referenced this pull request May 27, 2022
… digest. (Cherry-pick of #15652) (#15680)

Fixes #13899.

[ci skip-build-wheels]
stuhood added a commit that referenced this pull request May 27, 2022
… digest. (Cherry-pick of #15652) (#15679)

Fixes #13899.

[ci skip-build-wheels]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bugfix Bug fixes for released features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Permission denied" while creating sandbox with immutable inputs
4 participants