15954: Install go binaries to tempdir.
authorTom Clegg <tom@tomclegg.ca>
Mon, 24 Feb 2020 15:23:53 +0000 (10:23 -0500)
committerTom Clegg <tom@tomclegg.ca>
Mon, 24 Feb 2020 20:30:07 +0000 (15:30 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/boot/cmd.go
lib/boot/service.go

index 2c3103202427237e94863d5393d1d1bee698a360..a360a0b4eedf2b745a36bee6feb6dfaa109216fa 100644 (file)
@@ -175,6 +175,9 @@ func (boot *Booter) run(cfg *arvados.Config) error {
                return err
        }
        defer os.RemoveAll(boot.tempdir)
+       if err := os.Mkdir(filepath.Join(boot.tempdir, "bin"), 0777); err != nil {
+               return err
+       }
 
        // Fill in any missing config keys, and write the resulting
        // config in the temp dir for child services to use.
@@ -202,6 +205,7 @@ func (boot *Booter) run(cfg *arvados.Config) error {
        boot.setEnv("ARVADOS_CONFIG", boot.configfile)
        boot.setEnv("RAILS_ENV", boot.ClusterType)
        boot.setEnv("TMPDIR", boot.tempdir)
+       boot.prependEnv("PATH", filepath.Join(boot.tempdir, "bin")+":")
        boot.prependEnv("PATH", filepath.Join(boot.LibPath, "bin")+":")
 
        boot.cluster, err = cfg.GetCluster("")
@@ -412,7 +416,7 @@ func dedupEnv(in []string) []string {
 func (boot *Booter) installGoProgram(ctx context.Context, srcpath string) error {
        boot.goMutex.Lock()
        defer boot.goMutex.Unlock()
-       return boot.RunProgram(ctx, filepath.Join(boot.SourcePath, srcpath), nil, []string{"GOPATH=" + boot.LibPath}, "go", "install")
+       return boot.RunProgram(ctx, filepath.Join(boot.SourcePath, srcpath), nil, []string{"GOBIN=" + boot.tempdir + "/bin"}, "go", "install")
 }
 
 func (boot *Booter) setupRubyEnv() error {
index 4b35e13768c9169de8df004be19cf6099f3cb072..8cfea565ad1b3b8f3a257c8b6dde4446568f7d84 100644 (file)
@@ -45,7 +45,8 @@ func (runner runGoProgram) String() string {
 
 func (runner runGoProgram) Run(ctx context.Context, fail func(error), boot *Booter) error {
        boot.wait(ctx, runner.depends...)
-       err := boot.RunProgram(ctx, runner.src, nil, nil, "go", "install")
+       bindir := filepath.Join(boot.tempdir, "bin")
+       err := boot.RunProgram(ctx, runner.src, nil, []string{"GOBIN=" + bindir}, "go", "install")
        if err != nil {
                return err
        }
@@ -53,6 +54,8 @@ func (runner runGoProgram) Run(ctx context.Context, fail func(error), boot *Boot
                return ctx.Err()
        }
        _, basename := filepath.Split(runner.src)
+       binfile := filepath.Join(bindir, basename)
+
        if len(runner.svc.InternalURLs) > 0 {
                // Run one for each URL
                for u := range runner.svc.InternalURLs {
@@ -60,7 +63,7 @@ func (runner runGoProgram) Run(ctx context.Context, fail func(error), boot *Boot
                        boot.waitShutdown.Add(1)
                        go func() {
                                defer boot.waitShutdown.Done()
-                               fail(boot.RunProgram(ctx, boot.tempdir, nil, []string{"ARVADOS_SERVICE_INTERNAL_URL=" + u.String()}, basename))
+                               fail(boot.RunProgram(ctx, boot.tempdir, nil, []string{"ARVADOS_SERVICE_INTERNAL_URL=" + u.String()}, binfile))
                        }()
                }
        } else {
@@ -68,7 +71,7 @@ func (runner runGoProgram) Run(ctx context.Context, fail func(error), boot *Boot
                boot.waitShutdown.Add(1)
                go func() {
                        defer boot.waitShutdown.Done()
-                       fail(boot.RunProgram(ctx, boot.tempdir, nil, nil, basename))
+                       fail(boot.RunProgram(ctx, boot.tempdir, nil, nil, binfile))
                }()
        }
        return nil