From 88fc6bbebeff1c0db0e43fb0a83d2b03a973da8a Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 4 Mar 2025 18:22:35 +0400 Subject: [PATCH] test: fix UKI preserving talos.config and image cache Fix image cache installer ref, and preserve talos.config with UKIs for `talosctl cluster create`. Signed-off-by: Andrey Smirnov --- Makefile | 2 +- internal/integration/cli/image.go | 2 +- internal/integration/cli/list.go | 2 +- pkg/provision/providers/qemu/launch.go | 15 +++++++++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 1d098760d..5eaf522e3 100644 --- a/Makefile +++ b/Makefile @@ -519,7 +519,7 @@ uki-certs: talosctl ## Generate test certificates for SecureBoot/PCR Signing .PHONY: cache-create cache-create: installer imager ## Generate image cache. @docker run --entrypoint /usr/local/bin/e2e.test registry.k8s.io/conformance:$(KUBECTL_VERSION) --list-images | \ - $(TALOSCTL_EXECUTABLE) images integration --installer-tag=$(IMAGE_TAG)-amd64-secureboot --registry-and-user=$(REGISTRY_AND_USERNAME) | \ + $(TALOSCTL_EXECUTABLE) images integration --installer-tag=$(IMAGE_TAG) --registry-and-user=$(REGISTRY_AND_USERNAME) | \ $(TALOSCTL_EXECUTABLE) images cache-create --image-cache-path=/tmp/cache.tar --images=- --force @crane push /tmp/cache.tar $(REGISTRY_AND_USERNAME)/image-cache:$(IMAGE_TAG) @$(MAKE) image-iso IMAGER_ARGS="--image-cache=$(REGISTRY_AND_USERNAME)/image-cache:$(IMAGE_TAG) --extra-kernel-arg='console=ttyS0'" diff --git a/internal/integration/cli/image.go b/internal/integration/cli/image.go index 7fe243cc7..e16dab23b 100644 --- a/internal/integration/cli/image.go +++ b/internal/integration/cli/image.go @@ -48,7 +48,7 @@ func (suite *ImageSuite) TestList() { ) } -var imageCacheQuery = []string{"get", "imagecacheconfig", "--output", "jsonpath='{.spec.copyStatus}'"} +var imageCacheQuery = []string{"get", "imagecacheconfig", "--output", "jsonpath='{.spec.status}'"} // TestPull verifies pulling images to the CRI. func (suite *ImageSuite) TestPull() { diff --git a/internal/integration/cli/list.go b/internal/integration/cli/list.go index 782f8bbb2..2e805b1f5 100644 --- a/internal/integration/cli/list.go +++ b/internal/integration/cli/list.go @@ -51,7 +51,7 @@ func (suite *ListSuite) TestDepth() { if stdout, _ := suite.RunCLI(imageCacheQuery); strings.Contains(stdout, "ready") { // Image cache paths parts are longer - maxSeps = 9 + maxSeps = 8 } // checks that enough separators are encountered in the output diff --git a/pkg/provision/providers/qemu/launch.go b/pkg/provision/providers/qemu/launch.go index ae18891ec..89de81eb9 100644 --- a/pkg/provision/providers/qemu/launch.go +++ b/pkg/provision/providers/qemu/launch.go @@ -87,6 +87,10 @@ type LaunchConfig struct { // API APIPort int + // sd-stub + sdStubExtraCmdline string + sdStubExtraCmdlineConfig string + // filled by CNI invocation tapName string vmMAC string @@ -319,7 +323,7 @@ func launchVM(config *LaunchConfig) error { "-no-reboot", "-boot", fmt.Sprintf("order=%s,reboot-timeout=5000", bootOrder), "-smbios", fmt.Sprintf("type=1,uuid=%s", config.NodeUUID), - "-smbios", "type=11,value=io.systemd.stub.kernel-cmdline-extra=console=ttyS0", + "-smbios", fmt.Sprintf("type=11,value=io.systemd.stub.kernel-cmdline-extra=%s", config.sdStubExtraCmdline), "-chardev", fmt.Sprintf("socket,path=%s/%s.sock,server=on,wait=off,id=qga0", config.StatePath, config.Hostname), "-device", "virtio-serial", "-device", "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0", @@ -487,12 +491,14 @@ func launchVM(config *LaunchConfig) error { "-kernel", config.UKIPath, "-append", config.KernelArgs, ) + config.sdStubExtraCmdline += config.sdStubExtraCmdlineConfig case config.KernelImagePath != "": args = append(args, "-kernel", config.KernelImagePath, "-initrd", config.InitrdPath, "-append", config.KernelArgs, ) + config.sdStubExtraCmdline += config.sdStubExtraCmdlineConfig } } @@ -592,7 +598,12 @@ func Launch() error { defer httpServer.Shutdown(ctx) //nolint:errcheck // patch kernel args - config.KernelArgs = strings.ReplaceAll(config.KernelArgs, "{TALOS_CONFIG_URL}", fmt.Sprintf("http://%s/config.yaml", httpServer.GetAddr())) + config.sdStubExtraCmdline = "console=ttyS0" + + if strings.Contains(config.KernelArgs, "{TALOS_CONFIG_URL}") { + config.KernelArgs = strings.ReplaceAll(config.KernelArgs, "{TALOS_CONFIG_URL}", fmt.Sprintf("http://%s/config.yaml", httpServer.GetAddr())) + config.sdStubExtraCmdlineConfig = fmt.Sprintf(" talos.config=http://%s/config.yaml", httpServer.GetAddr()) + } return withCNI(ctx, &config, func(config *LaunchConfig) error { for {