From ea0508a634f7d76731f062e034feea8b75f74be1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 Jun 2022 16:29:02 +0800 Subject: [PATCH] [Backport release-1.4] Fix: hold the force uninstalling process untill the last addon been deleted (#4103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * hold the force uninstalling process untill the last addon been deleted Signed-off-by: 楚岳 fix lint Signed-off-by: 楚岳 fix comments Signed-off-by: 楚岳 fix comments Signed-off-by: 楚岳 (cherry picked from commit 1d4266432c0e2617fdcd100164bd94329bc07d77) * fix comments Signed-off-by: 楚岳 fix lint Signed-off-by: 楚岳 (cherry picked from commit cecd8c28d036512726ddd6ec5854f2dabf781ec9) * add period Signed-off-by: 楚岳 (cherry picked from commit 62e4dac5386500e7c9cc59607c34dd6f4f704607) Co-authored-by: 楚岳 --- references/cli/uninstall.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/references/cli/uninstall.go b/references/cli/uninstall.go index 6d9859d66..cd9a4c00a 100644 --- a/references/cli/uninstall.go +++ b/references/cli/uninstall.go @@ -209,6 +209,21 @@ func forceDisableAddon(ctx context.Context, kubeClient client.Client, config *re if err := pkgaddon.DisableAddon(ctx, kubeClient, "fluxcd", config, true); err != nil { return err } + timeConsumed = time.Now() + for { + if time.Now().After(timeConsumed.Add(5 * time.Minute)) { + return errors.New("timeout disable fluxcd addon, please disable the addon manually") + } + addons, err := checkInstallAddon(kubeClient) + if err != nil { + return err + } + if len(addons) == 0 { + break + } + fmt.Printf("Waiting delete the fluxcd addon, timeout left %s . \r\n", 5*time.Minute-time.Since(timeConsumed)) + time.Sleep(2 * time.Second) + } } return nil }