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

Enable plz build --shell` to work correctly with remote execution and subrepos #3066

Merged
merged 4 commits into from
Feb 7, 2024

Conversation

janhancic
Copy link
Member

Instead of trying to move files around after everything is built, we instead simply download all the original target's inputs from CAS when running in remote execution mode.

…nd subrepos

Instead of trying to move files around after everything is built, we instead
simply download all the original target's inputs from CAS when running in
remote execution mode.
@@ -1298,6 +1301,7 @@ func (state *BuildState) GetPreloadedSubincludes() []BuildLabel {

// DownloadInputsIfNeeded downloads all the inputs (or runtime files) for a target if we are building remotely.
func (state *BuildState) DownloadInputsIfNeeded(target *BuildTarget, runtime bool) error {
// TODO(jan): Remove this function once `DownloadAllInputs` has been fully implemented across both build & test.
Copy link
Member

Choose a reason for hiding this comment

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

I don't really understand what is better about DownloadAllInputs vs. this. It just seems to be pushing the check of whether the remote client is set up out to the callers?

Copy link
Member Author

Choose a reason for hiding this comment

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

DownloadInputsIfNeeded works by looking at a list of specific inputs on a target and downloading those individually. DownloadAllInputs just graps the whole input directory and downloads it, without doing any of the IterInputs logic, etc.

Copy link
Member

Choose a reason for hiding this comment

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

It's a bit nuanced but the original bug we were seeing was due to the root field on the subrepo being different when running remotely vs. locally. When it's remote, the root is relative to the output directory of the target (we construct a Tree proto for the outputs and use this as the basis for the remote filesystem). Consumers of the subrepo in the remote package know to resolve these paths against the subrepo FS.

The problem is the IterInputs() code is for local execution and expects the paths to be relative to the host repo's root i.e. contain the plz-out/gen/subrepo_name. It uses the (*SubrepoFileLabel).FullPaths() function which returns a string list, which loses all information about the path being relative to the subrepo filesystem.

This was the simplest solution. We might've been able to make the subrepo root FS the same across local and remote execution if we munged the paths around in the remote package, but that would require wider sweeping changes.

@janhancic
Copy link
Member Author

I've discovered an issue with non-subrepo targets, so this PR isn't ready to go just yet sadly.

Copy link
Member

@Tatskaari Tatskaari left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 526 to 531
pbDir, err = c.uploadInputs(ch, target, isTest)
if err != nil {
return err
}

return nil
Copy link
Member

Choose a reason for hiding this comment

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

You can just return err without the nil check. If it's nil then that's fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

eh, of course ...

@@ -1298,6 +1301,7 @@ func (state *BuildState) GetPreloadedSubincludes() []BuildLabel {

// DownloadInputsIfNeeded downloads all the inputs (or runtime files) for a target if we are building remotely.
func (state *BuildState) DownloadInputsIfNeeded(target *BuildTarget, runtime bool) error {
// TODO(jan): Remove this function once `DownloadAllInputs` has been fully implemented across both build & test.
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit nuanced but the original bug we were seeing was due to the root field on the subrepo being different when running remotely vs. locally. When it's remote, the root is relative to the output directory of the target (we construct a Tree proto for the outputs and use this as the basis for the remote filesystem). Consumers of the subrepo in the remote package know to resolve these paths against the subrepo FS.

The problem is the IterInputs() code is for local execution and expects the paths to be relative to the host repo's root i.e. contain the plz-out/gen/subrepo_name. It uses the (*SubrepoFileLabel).FullPaths() function which returns a string list, which loses all information about the path being relative to the subrepo filesystem.

This was the simplest solution. We might've been able to make the subrepo root FS the same across local and remote execution if we munged the paths around in the remote package, but that would require wider sweeping changes.

@janhancic janhancic merged commit 1db4c6e into master Feb 7, 2024
14 checks passed
janhancic added a commit to janhancic/please that referenced this pull request Feb 8, 2024
janhancic added a commit that referenced this pull request Feb 8, 2024
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.

3 participants