From 21a34ead1ed194dda53c2c5ecb5075e8eb1652d7 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 5 Oct 2020 11:12:17 +0300 Subject: fixes for ws handline --- contractor | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/contractor b/contractor index 7b71437..9d06e34 100755 --- a/contractor +++ b/contractor @@ -23,6 +23,10 @@ WS_SIZE = "20G" WS_MNT = "/mnt" +# The device on the worker for the workspace disk. +WORKER_WS_DEV = "vdb" + + # The worker VM image file on manager VM. WORKER_IMG = "worker.img" @@ -268,6 +272,14 @@ class GetGID(RemoteExecution): return ["id", "-g"] +class RemoveWS(RemoteExecution): + def msg(self): + return "remove workspace image on manager" + + def argv(self): + return ["rm", "-f", WS_IMG] + + class CreateWS(RemoteExecution): def msg(self): return "creating workspace on manager" @@ -297,7 +309,7 @@ class MountWSonWorker(RemoteExecution): return "mounting workspace on worker" def argv(self): - return ["sudo", "mount", "/dev/vdb", "/workspace"] + return ["sudo", "mount", "/dev/{}".format(WORKER_WS_DEV), "/workspace"] class TryUnmountWS(MayFail): @@ -398,7 +410,7 @@ class AttachWS(RemoteExecution): "attach-disk", "worker", WS_IMG, - "vdb", + WORKER_WS_DEV, "--targetbus", "virtio", "--live", @@ -649,23 +661,14 @@ def cmd_build(args): manager_gid = int(er.stdout) with Timer(vrb, "start-worker"): - execs = [TryUnmountWS()] - exec_quietly(manager, *execs) - - with Timer(vrb, "start-worker"): - execs = [CreateWS()] - exec_quietly(manager, *execs) - - with Timer(vrb, "start-worker"): - execs = [MkfsWS()] - exec_quietly(manager, *execs) - - with Timer(vrb, "start-worker"): - execs = [MountWS()] - exec_quietly(manager, *execs) - - with Timer(vrb, "start-worker"): - execs = [ChownWS(manager_uid, manager_gid)] + execs = [ + TryUnmountWS(), + RemoveWS(), + CreateWS(), + MkfsWS(), + MountWS(), + ChownWS(manager_uid, manager_gid), + ] exec_quietly(manager, *execs) with Timer(vrb, "upload-saved-workspace"): -- cgit v1.2.1