21585: Updates installer's Terraform code to require IMDSv2 on service nodes.
[arvados.git] / lib / boot / workbench2.go
index 149487cdb649d4c4b6cbdc84f8c8a9e92a3537fb..8c8c607f4592d4cdc0784c55a832e227ad689923 100644 (file)
@@ -38,21 +38,30 @@ func (runner runWorkbench2) Run(ctx context.Context, fail func(error), super *Su
                                user: "www-data",
                        }, "arvados-server", "workbench2", super.cluster.Services.Controller.ExternalURL.Host, net.JoinHostPort(host, port), ".")
                } else {
-                       stdinr, stdinw := io.Pipe()
-                       defer stdinw.Close()
-                       go func() {
-                               <-ctx.Done()
-                               stdinw.Close()
-                       }()
-                       if err = os.Mkdir(super.SourcePath+"/services/workbench2/public/_health", 0777); err != nil && !errors.Is(err, fs.ErrExist) {
+                       // super.SourcePath might be readonly, so for
+                       // dev/test mode we make a copy in a writable
+                       // dir.
+                       livedir := super.wwwtempdir + "/workbench2"
+                       if err := super.RunProgram(ctx, super.SourcePath+"/services/workbench2", runOptions{}, "rsync", "-a", "--delete-after", super.SourcePath+"/services/workbench2/", livedir); err != nil {
+                               fail(err)
+                               return
+                       }
+                       if err = os.Mkdir(livedir+"/public/_health", 0777); err != nil && !errors.Is(err, fs.ErrExist) {
                                fail(err)
                                return
                        }
-                       if err = ioutil.WriteFile(super.SourcePath+"/services/workbench2/public/_health/ping", []byte(`{"health":"OK"}`), 0666); err != nil {
+                       if err = ioutil.WriteFile(livedir+"/public/_health/ping", []byte(`{"health":"OK"}`), 0666); err != nil {
                                fail(err)
                                return
                        }
-                       err = super.RunProgram(ctx, super.SourcePath+"/services/workbench2", runOptions{
+
+                       stdinr, stdinw := io.Pipe()
+                       defer stdinw.Close()
+                       go func() {
+                               <-ctx.Done()
+                               stdinw.Close()
+                       }()
+                       err = super.RunProgram(ctx, livedir, runOptions{
                                env: []string{
                                        "CI=true",
                                        "HTTPS=false",