From 5c4e1dfc39b693db2be8ab80a16aefea99c07b62 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 19 Jan 2024 19:21:17 -0500 Subject: [PATCH] fix: do not attempt to uninstall a chart that isn't available --- plugins/scheduler-k3s/helm.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/scheduler-k3s/helm.go b/plugins/scheduler-k3s/helm.go index 8b986f975..79bbfe993 100644 --- a/plugins/scheduler-k3s/helm.go +++ b/plugins/scheduler-k3s/helm.go @@ -273,9 +273,18 @@ func (h *HelmAgent) UpgradeChart(input ChartInput) error { } func (h *HelmAgent) UninstallChart(releaseName string) error { + exists, err := h.ChartExists(releaseName) + if err != nil { + return fmt.Errorf("Error checking if chart exists: %w", err) + } + + if !exists { + return nil + } + uninstall := action.NewUninstall(h.Configuration) uninstall.DeletionPropagation = "foreground" - _, err := uninstall.Run(releaseName) + _, err = uninstall.Run(releaseName) if err != nil { return fmt.Errorf("Error uninstalling chart: %w", err) }