Skip to content

Commit c550b0b

Browse files
Download run-time dependencies when running a target remotely (#3453)
The code path taken when `plz run`ning a binary target is slightly different for remote execution vs local execution - ensure the target's transitive run-time dependencies are all downloaded by the client before it runs the target.
1 parent 1b190e9 commit c550b0b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/remote/remote.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,13 @@ func (c *Client) Build(target *core.BuildTarget) (*core.BuildMetadata, error) {
351351
if err := c.Download(target); err != nil {
352352
return metadata, err
353353
}
354-
// TODO(peterebden): Should this not just be part of Download()?
354+
// TODO(peterebden): Should these not just be part of Download()?
355355
if err := c.downloadData(target); err != nil {
356356
return metadata, err
357357
}
358+
if err := c.downloadRuntimeDependencies(target); err != nil {
359+
return metadata, err
360+
}
358361
}
359362
return metadata, nil
360363
}
@@ -376,6 +379,22 @@ func (c *Client) downloadData(target *core.BuildTarget) error {
376379
return g.Wait()
377380
}
378381

382+
// downloadRuntimeDependencies downloads all the runtime dependencies for a target.
383+
func (c *Client) downloadRuntimeDependencies(target *core.BuildTarget) error {
384+
var g errgroup.Group
385+
for runDep := range target.IterAllRuntimeDependencies(c.state.Graph) {
386+
l, _ := runDep.Label()
387+
t := c.state.Graph.TargetOrDie(l)
388+
g.Go(func() error {
389+
if err := c.Download(t); err != nil {
390+
return err
391+
}
392+
return nil
393+
})
394+
}
395+
return g.Wait()
396+
}
397+
379398
// Run runs a target on the remote executors.
380399
func (c *Client) Run(target *core.BuildTarget) error {
381400
if err := c.CheckInitialised(); err != nil {

0 commit comments

Comments
 (0)