From aa57b85a7583dcad7f7380fe920375068c5678ee Mon Sep 17 00:00:00 2001 From: Jonathan Poole Date: Wed, 3 Jan 2024 16:29:36 +0000 Subject: [PATCH] Handle .out temp output suffix for remote execution (#3008) --- src/remote/action.go | 4 ++-- src/remote/utils.go | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/remote/action.go b/src/remote/action.go index 5b30d94188..8e9eb34163 100644 --- a/src/remote/action.go +++ b/src/remote/action.go @@ -395,7 +395,7 @@ func (c *Client) buildMetadata(target *core.BuildTarget, ar *pb.ActionResult, ne } metadata.Stderr = b } - outputs, err := c.outputTree(ar) + outputs, err := c.outputTree(target, ar) if err != nil { return nil, err } @@ -527,7 +527,7 @@ func (c *Client) uploadLocalTarget(target *core.BuildTarget) error { if err := c.uploadIfMissing(context.Background(), entries); err != nil { return err } - outs, err := c.outputTree(ar) + outs, err := c.outputTree(target, ar) if err != nil { return err } diff --git a/src/remote/utils.go b/src/remote/utils.go index 3a786a30c9..2e82342907 100644 --- a/src/remote/utils.go +++ b/src/remote/utils.go @@ -68,8 +68,9 @@ func (c *Client) targetOutputs(label core.BuildLabel) *pb.Directory { return c.outputs[label] } -// setOutputs sets the outputs for the target so we can refer to them later by build label from dependent rules. We also -// save the full Tree proto for subrepos so we can parse and build subrepo targets without downloading the sources. +// setOutputs sets the outputs for the target, so we can refer to them later by build label from dependent rules. We +// also save the full Tree proto for subrepos, so we can parse and build subrepo targets without downloading the +// sources. func (c *Client) setOutputs(target *core.BuildTarget, arTree *pb.Tree) error { c.outputMutex.Lock() defer c.outputMutex.Unlock() @@ -131,7 +132,7 @@ func (c *Client) setOutputsFromMetadata(target *core.BuildTarget, md *core.Build } // outputTree returns a tree representing the outputs of an action result -func (c *Client) outputTree(ar *pb.ActionResult) (*pb.Tree, error) { +func (c *Client) outputTree(target *core.BuildTarget, ar *pb.ActionResult) (*pb.Tree, error) { o := &pb.Tree{ Root: &pb.Directory{ Files: make([]*pb.FileNode, len(ar.OutputFiles)), @@ -146,7 +147,7 @@ func (c *Client) outputTree(ar *pb.ActionResult) (*pb.Tree, error) { // uploadInputDir. for i, f := range ar.OutputFiles { o.Root.Files[i] = &pb.FileNode{ - Name: f.Path, + Name: target.GetRealOutput(f.Path), Digest: f.Digest, IsExecutable: f.IsExecutable, } @@ -159,13 +160,13 @@ func (c *Client) outputTree(ar *pb.ActionResult) (*pb.Tree, error) { } o.Children = append(o.Children, append(tree.Children, tree.Root)...) o.Root.Directories = append(o.Root.Directories, &pb.DirectoryNode{ - Name: d.Path, + Name: target.GetRealOutput(d.Path), Digest: c.digestMessage(tree.Root), }) } for i, s := range append(ar.OutputFileSymlinks, ar.OutputDirectorySymlinks...) { o.Root.Symlinks[i] = &pb.SymlinkNode{ - Name: s.Path, + Name: target.GetRealOutput(s.Path), Target: s.Target, } } @@ -443,7 +444,7 @@ func (b *dirBuilder) dir(dir, child string) *pb.Directory { return d } -// Build "builds" the directory. It calculate the digests of all the items in the directory tree, and returns the root +// Build "builds" the directory. It calculates the digests of all the items in the directory tree, and returns the root // directory. If ch is non-nil, it will upload the directory protos to ch. Build doesn't upload any of the actual files // in the directory tree, just the protos. func (b *dirBuilder) Build(ch chan<- *uploadinfo.Entry) *pb.Directory {