From 5a9f9c0a520b38f5374f9985ba44fe9b05f4b069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= <66256922+daniel-weisse@users.noreply.github.com> Date: Fri, 30 Jun 2023 15:13:29 +0200 Subject: [PATCH] bootstraper: delete helm chart on installation failure before retrying installation (#1977) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Delete helm chart on failure before retrying installation * Add chart name to debug output * Remove now unused wait flag from helm Release struct --------- Signed-off-by: Daniel Weiße --- bootstrapper/internal/helm/helm.go | 13 +++++++------ cli/internal/helm/loader.go | 2 +- internal/deploy/helm/helm.go | 1 - 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bootstrapper/internal/helm/helm.go b/bootstrapper/internal/helm/helm.go index d8fd8f7d7..cd354a295 100644 --- a/bootstrapper/internal/helm/helm.go +++ b/bootstrapper/internal/helm/helm.go @@ -57,6 +57,8 @@ func New(log *logger.Logger) (*Client, error) { action := action.NewInstall(actionConfig) action.Namespace = constants.HelmNamespace action.Timeout = timeout + action.Atomic = true + action.Wait = true return &Client{ action, @@ -67,7 +69,6 @@ func New(log *logger.Logger) (*Client, error) { // InstallConstellationServices installs the constellation-services chart. In the future this chart should bundle all microservices. func (h *Client) InstallConstellationServices(ctx context.Context, release helm.Release, extraVals map[string]any) error { h.ReleaseName = release.ReleaseName - h.Wait = release.Wait mergedVals := helm.MergeMaps(release.Values, extraVals) @@ -77,7 +78,6 @@ func (h *Client) InstallConstellationServices(ctx context.Context, release helm. // InstallCertManager installs the cert-manager chart. func (h *Client) InstallCertManager(ctx context.Context, release helm.Release) error { h.ReleaseName = release.ReleaseName - h.Wait = release.Wait h.Timeout = 10 * time.Minute return h.install(ctx, release.Chart, release.Values) @@ -86,7 +86,6 @@ func (h *Client) InstallCertManager(ctx context.Context, release helm.Release) e // InstallOperators installs the Constellation Operators. func (h *Client) InstallOperators(ctx context.Context, release helm.Release, extraVals map[string]any) error { h.ReleaseName = release.ReleaseName - h.Wait = release.Wait mergedVals := helm.MergeMaps(release.Values, extraVals) @@ -96,7 +95,6 @@ func (h *Client) InstallOperators(ctx context.Context, release helm.Release, ext // InstallCilium sets up the cilium pod network. func (h *Client) InstallCilium(ctx context.Context, kubectl k8sapi.Client, release helm.Release, in k8sapi.SetupPodNetworkInput) error { h.ReleaseName = release.ReleaseName - h.Wait = release.Wait timeoutS := int64(10) // allow coredns to run on uninitialized nodes (required by cloud-controller-manager) @@ -215,7 +213,10 @@ type installDoer struct { func (i installDoer) Do(ctx context.Context) error { i.log.With(zap.String("chart", i.chart.Name())).Infof("Trying to install Helm chart") - _, err := i.client.RunWithContext(ctx, i.chart, i.values) + if _, err := i.client.RunWithContext(ctx, i.chart, i.values); err != nil { + i.log.With(zap.Error(err), zap.String("chart", i.chart.Name())).Errorf("Helm chart installation failed") + return err + } - return err + return nil } diff --git a/cli/internal/helm/loader.go b/cli/internal/helm/loader.go index 840914969..27bdbfb33 100644 --- a/cli/internal/helm/loader.go +++ b/cli/internal/helm/loader.go @@ -168,7 +168,7 @@ func (i *ChartLoader) loadRelease(info chartInfo) (helm.Release, error) { return helm.Release{}, fmt.Errorf("packaging %s chart: %w", info.releaseName, err) } - return helm.Release{Chart: chartRaw, Values: values, ReleaseName: info.releaseName, Wait: false}, nil + return helm.Release{Chart: chartRaw, Values: values, ReleaseName: info.releaseName}, nil } // loadCiliumValues is used to separate the marshalling step from the loading step. diff --git a/internal/deploy/helm/helm.go b/internal/deploy/helm/helm.go index 38f304155..8170bbef9 100644 --- a/internal/deploy/helm/helm.go +++ b/internal/deploy/helm/helm.go @@ -12,7 +12,6 @@ type Release struct { Chart []byte Values map[string]any ReleaseName string - Wait bool } // Releases bundles all helm releases to be deployed to Constellation.