From c40bb449baeeff3f03279e5f11bff811393ab895 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Thu, 12 Jun 2025 05:46:21 +0000 Subject: [PATCH] Fix rootless e2e test The install script was starting the service, and then the test itself was restarting it immediately thereafter, which caused frequent flakes. Signed-off-by: Brad Davidson --- tests/e2e/rootless/rootless_test.go | 11 +++++++---- tests/e2e/scripts/setup_rootless.sh | 2 -- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/e2e/rootless/rootless_test.go b/tests/e2e/rootless/rootless_test.go index 6ebb541e85..6eea707fe1 100644 --- a/tests/e2e/rootless/rootless_test.go +++ b/tests/e2e/rootless/rootless_test.go @@ -37,7 +37,7 @@ func StartK3sCluster(nodes []e2e.VagrantNode, serverYAML string) error { resetCmd := "head -n 3 /etc/rancher/k3s/config.yaml > /tmp/config.yaml && sudo mv /tmp/config.yaml /etc/rancher/k3s/config.yaml" yamlCmd := fmt.Sprintf("echo '%s' >> /etc/rancher/k3s/config.yaml", serverYAML) - startCmd := "systemctl --user restart k3s-rootless" + startCmd := "systemctl --user start k3s-rootless" if _, err := node.RunCmdOnNode(resetCmd); err != nil { return err @@ -95,9 +95,12 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { By("CLUSTER CONFIG") By("OS: " + *nodeOS) By(tc.Status()) - kubeConfigFile, err := GenRootlessKubeconfigFile(tc.Servers[0].String()) - Expect(err).NotTo(HaveOccurred()) - tc.KubeconfigFile = kubeConfigFile + + Eventually(func() error { + kubeConfigFile, err := GenRootlessKubeconfigFile(tc.Servers[0].String()) + tc.KubeconfigFile = kubeConfigFile + return err + }, "360s", "5s").Should(Succeed()) }) It("Checks node and pod status", func() { diff --git a/tests/e2e/scripts/setup_rootless.sh b/tests/e2e/scripts/setup_rootless.sh index c3569eb954..fca31e71cc 100755 --- a/tests/e2e/scripts/setup_rootless.sh +++ b/tests/e2e/scripts/setup_rootless.sh @@ -54,5 +54,3 @@ systemctl daemon-reload loginctl enable-linger vagrant # We need to run this as vagrant user, because rootless k3s will be run as vagrant user su -c 'XDG_RUNTIME_DIR="/run/user/$UID" DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus" systemctl --user daemon-reload' vagrant -su -c 'XDG_RUNTIME_DIR="/run/user/$UID" DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus" systemctl --user enable --now k3s-rootless' vagrant -