18874: Fix wb2 install/boot to accommodate readonly source tree.
authorTom Clegg <tom@curii.com>
Sun, 12 Nov 2023 01:07:16 +0000 (20:07 -0500)
committerTom Clegg <tom@curii.com>
Sun, 12 Nov 2023 06:02:40 +0000 (01:02 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/boot/workbench2.go
lib/install/deps.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",
index 4dcbf889949fc99949919fc1880c2fb4394d0c2a..de61c5cd43ac38e3b8f86c8d2af7cbe737dd4691 100644 (file)
@@ -691,9 +691,12 @@ done
 
                // Install workbench2 app to /var/lib/arvados/workbench2/
                if err = inst.runBash(`
-cd "`+inst.SourcePath+`/services/workbench2"
-VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT="`+inst.Commit[:9]+`" yarn build
-rsync -a --delete-after build/ /var/lib/arvados/workbench2/
+src="`+inst.SourcePath+`/services/workbench2"
+tmp=/var/lib/arvados/tmp/workbench2
+dst=/var/lib/arvados/workbench2
+rsync -a --delete-after "$src/" "$tmp/"
+env -C "$tmp" VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT="`+inst.Commit[:9]+`" yarn build
+rsync -a --delete-after "$tmp/build/" "$dst/"
 `, stdout, stderr); err != nil {
                        return 1
                }