metropolis/launch: expose VNC socket
This can be used to manually test our upcoming console terminal.
Drive-by add a timeout to retrieving initial cluster credentials in
test, as this wasn't capped and caused tests to fail at the Bazel 300
sec timeout for a trivial case of a misconfigured qemu that wouldn't
launch.
Change-Id: I31fe8b82f3d7ad606c0ca1b03f51373fc746d499
Reviewed-on: https://review.monogon.dev/c/monogon/+/3370
Tested-by: Jenkins CI
Reviewed-by: Leopold Schabel <leo@monogon.tech>
diff --git a/metropolis/test/launch/cluster.go b/metropolis/test/launch/cluster.go
index 1435925..29096b8 100644
--- a/metropolis/test/launch/cluster.go
+++ b/metropolis/test/launch/cluster.go
@@ -107,6 +107,11 @@
// Runtime keeps the node's QEMU runtime state.
Runtime *NodeRuntime
+
+ // RunVNC starts a VNC socket for troubleshooting/testing console code. Note:
+ // this will not work in tests, as those use a built-in qemu which does not
+ // implement a VGA device.
+ RunVNC bool
}
// NodeRuntime keeps the node's QEMU runtime options.
@@ -284,7 +289,7 @@
qemuArgs := []string{
"-machine", "q35",
"-accel", "kvm",
- "-nographic",
+ "-display", "none",
"-nodefaults",
"-cpu", "host",
"-m", fmt.Sprintf("%dM", options.MemoryMiB),
@@ -300,6 +305,13 @@
"-device", "virtio-rng-pci",
"-serial", "stdio",
}
+ if options.RunVNC {
+ vncSocketPath := filepath.Join(r.sd, "vnc-socket")
+ qemuArgs = append(qemuArgs,
+ "-vnc", "unix:"+vncSocketPath,
+ "-device", "virtio-vga",
+ )
+ }
if !options.AllowReboot {
qemuArgs = append(qemuArgs, "-no-reboot")
@@ -673,7 +685,7 @@
}
}
return backoff.Permanent(err)
- }, backoff.WithContext(backoff.NewExponentialBackOff(), ctx))
+ }, backoff.WithContext(backoff.NewExponentialBackOff(backoff.WithMaxElapsedTime(time.Minute)), ctx))
if err != nil {
return nil, nil, fmt.Errorf("couldn't retrieve owner certificate: %w", err)
}