From d71184d674300af296eae6903018e88877afea26 Mon Sep 17 00:00:00 2001 From: Maisem Ali Date: Fri, 29 Sep 2023 09:08:49 -0700 Subject: [PATCH] cmd/containerboot: only wipeout serve config when TS_SERVE_CONFIG is set Fixes #9558 Signed-off-by: Maisem Ali --- cmd/containerboot/main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/containerboot/main.go b/cmd/containerboot/main.go index 59da2c062..09dc5f146 100644 --- a/cmd/containerboot/main.go +++ b/cmd/containerboot/main.go @@ -258,10 +258,13 @@ authLoop: if err := tailscaleSet(ctx, cfg); err != nil { log.Fatalf("failed to auth tailscale: %v", err) } - // Remove any serve config that may have been set by a previous - // run of containerboot. - if err := client.SetServeConfig(ctx, new(ipn.ServeConfig)); err != nil { - log.Fatalf("failed to unset serve config: %v", err) + + if cfg.ServeConfigPath != "" { + // Remove any serve config that may have been set by a previous run of + // containerboot, but only if we're providing a new one. + if err := client.SetServeConfig(ctx, new(ipn.ServeConfig)); err != nil { + log.Fatalf("failed to unset serve config: %v", err) + } } if cfg.InKubernetes && cfg.KubeSecret != "" && cfg.KubernetesCanPatch && cfg.AuthOnce {