From f48b8ab95306f117ca3d0ab2c17bb951fb97ed69 Mon Sep 17 00:00:00 2001 From: Santosh Kewat Date: Tue, 1 Jun 2021 15:09:58 +0530 Subject: [PATCH] Added support for helm waitForJobs Signed-off-by: Santosh Kewat Added support for helm waitForJobs Signed-off-by: Santosh Kewat Minor fixes Signed-off-by: Santosh Kewat Changed WaitForJobs to DisableWaitForJobs Signed-off-by: Santosh Kewat Minor fixes Signed-off-by: Santosh Kewat Changed WaitForJobs to DisableWaitForJobs Signed-off-by: Santosh Kewat Removed unnecessary update to v2alpha1 Signed-off-by: Santosh Kewat --- api/v2beta1/helmrelease_types.go | 15 +++++++ .../helm.toolkit.fluxcd.io_helmreleases.yaml | 12 ++++++ docs/api/helmrelease.md | 39 +++++++++++++++++++ docs/spec/v2beta1/helmreleases.md | 18 +++++++++ internal/runner/runner.go | 3 ++ 5 files changed, 87 insertions(+) diff --git a/api/v2beta1/helmrelease_types.go b/api/v2beta1/helmrelease_types.go index e645a32..27b1b0f 100644 --- a/api/v2beta1/helmrelease_types.go +++ b/api/v2beta1/helmrelease_types.go @@ -319,6 +319,11 @@ type Install struct { // +optional DisableWait bool `json:"disableWait,omitempty"` + // DisableWaitForJobs disables waiting for jobs to complete after a Helm + // install has been performed. + // +optional + DisableWaitForJobs bool `json:"disableWaitForJobs,omitempty"` + // DisableHooks prevents hooks from running during the Helm install action. // +optional DisableHooks bool `json:"disableHooks,omitempty"` @@ -490,6 +495,11 @@ type Upgrade struct { // +optional DisableWait bool `json:"disableWait,omitempty"` + // DisableWaitForJobs disables waiting for jobs to complete after a Helm + // upgrade has been performed. + // +optional + DisableWaitForJobs bool `json:"disableWaitForJobs,omitempty"` + // DisableHooks prevents hooks from running during the Helm upgrade action. // +optional DisableHooks bool `json:"disableHooks,omitempty"` @@ -686,6 +696,11 @@ type Rollback struct { // +optional DisableWait bool `json:"disableWait,omitempty"` + // DisableWaitForJobs disables waiting for jobs to complete after a Helm + // rollback has been performed. + // +optional + DisableWaitForJobs bool `json:"disableWaitForJobs,omitempty"` + // DisableHooks prevents hooks from running during the Helm rollback action. // +optional DisableHooks bool `json:"disableHooks,omitempty"` diff --git a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml index d43bb44..3dd5e4a 100644 --- a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml +++ b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml @@ -178,6 +178,10 @@ spec: description: DisableWait disables the waiting for resources to be ready after a Helm install has been performed. type: boolean + disableWaitForJobs: + description: DisableWaitForJobs disables waiting for jobs to complete + after a Helm install has been performed. + type: boolean remediation: description: Remediation holds the remediation configuration for when the Helm install action for the HelmRelease fails. The @@ -393,6 +397,10 @@ spec: description: DisableWait disables the waiting for resources to be ready after a Helm rollback has been performed. type: boolean + disableWaitForJobs: + description: DisableWaitForJobs disables waiting for jobs to complete + after a Helm rollback has been performed. + type: boolean force: description: Force forces resource updates through a replacement strategy. @@ -509,6 +517,10 @@ spec: description: DisableWait disables the waiting for resources to be ready after a Helm upgrade has been performed. type: boolean + disableWaitForJobs: + description: DisableWaitForJobs disables waiting for jobs to complete + after a Helm upgrade has been performed. + type: boolean force: description: Force forces resource updates through a replacement strategy. diff --git a/docs/api/helmrelease.md b/docs/api/helmrelease.md index 2c11b54..d3e5165 100644 --- a/docs/api/helmrelease.md +++ b/docs/api/helmrelease.md @@ -1169,6 +1169,19 @@ install has been performed.

+disableWaitForJobs
+ +bool + + + +(Optional) +

DisableWaitForJobs disables waiting for jobs to complete after a Helm +install has been performed.

+ + + + disableHooks
bool @@ -1526,6 +1539,19 @@ rollback has been performed.

+disableWaitForJobs
+ +bool + + + +(Optional) +

DisableWaitForJobs disables waiting for jobs to complete after a Helm +rollback has been performed.

+ + + + disableHooks
bool @@ -1767,6 +1793,19 @@ upgrade has been performed.

+disableWaitForJobs
+ +bool + + + +(Optional) +

DisableWaitForJobs disables waiting for jobs to complete after a Helm +upgrade has been performed.

+ + + + disableHooks
bool diff --git a/docs/spec/v2beta1/helmreleases.md b/docs/spec/v2beta1/helmreleases.md index edd6284..aa04144 100644 --- a/docs/spec/v2beta1/helmreleases.md +++ b/docs/spec/v2beta1/helmreleases.md @@ -190,6 +190,11 @@ type Install struct { // +optional DisableWait bool `json:"disableWait,omitempty"` + // DisableWaitForJobs disables waiting for jobs to complete after a Helm + // install has been performed. + // +optional + DisableWaitForJobs bool `json:"disableWaitForJobs,omitempty"` + // DisableHooks prevents hooks from running during the Helm install action. // +optional DisableHooks bool `json:"disableHooks,omitempty"` @@ -280,6 +285,11 @@ type Upgrade struct { // +optional DisableWait bool `json:"disableWait,omitempty"` + // DisableWaitForJobs disables waiting for jobs to complete after a Helm + // upgrade has been performed. + // +optional + DisableWaitForJobs bool `json:"disableWaitForJobs,omitempty"` + // DisableHooks prevents hooks from running during the Helm upgrade action. // +optional DisableHooks bool `json:"disableHooks,omitempty"` @@ -383,6 +393,11 @@ type Rollback struct { // +optional DisableWait bool `json:"disableWait,omitempty"` + // DisableWaitForJobs disables waiting for jobs to complete after a Helm + // rollback has been performed. + // +optional + DisableWaitForJobs bool `json:"disableWaitForJobs,omitempty"` + // DisableHooks prevents hooks from running during the Helm rollback action. // +optional DisableHooks bool `json:"disableHooks,omitempty"` @@ -770,6 +785,9 @@ kubectl get all --all-namespaces \ For install, upgrade, and rollback actions resource waiting is enabled by default, but can be disabled by setting `spec..disableWait`. +Waiting for jobs to complete is enabled by default, +but can be disabled by setting `spec..disableWaitForJobs`. + ### `HelmRelease` dependencies When applying a `HelmRelease`, you may need to make sure other releases are [Ready](#status) diff --git a/internal/runner/runner.go b/internal/runner/runner.go index ccfe1a0..9ffd92c 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -106,6 +106,7 @@ func (r *Runner) Install(hr v2.HelmRelease, chart *chart.Chart, values chartutil install.Namespace = hr.GetReleaseNamespace() install.Timeout = hr.Spec.GetInstall().GetTimeout(hr.GetTimeout()).Duration install.Wait = !hr.Spec.GetInstall().DisableWait + install.WaitForJobs = !hr.Spec.GetInstall().DisableWaitForJobs install.DisableHooks = hr.Spec.GetInstall().DisableHooks install.DisableOpenAPIValidation = hr.Spec.GetInstall().DisableOpenAPIValidation install.Replace = hr.Spec.GetInstall().Replace @@ -156,6 +157,7 @@ func (r *Runner) Upgrade(hr v2.HelmRelease, chart *chart.Chart, values chartutil upgrade.MaxHistory = hr.GetMaxHistory() upgrade.Timeout = hr.Spec.GetUpgrade().GetTimeout(hr.GetTimeout()).Duration upgrade.Wait = !hr.Spec.GetUpgrade().DisableWait + upgrade.WaitForJobs = !hr.Spec.GetUpgrade().DisableWaitForJobs upgrade.DisableHooks = hr.Spec.GetUpgrade().DisableHooks upgrade.Force = hr.Spec.GetUpgrade().Force upgrade.CleanupOnFail = hr.Spec.GetUpgrade().CleanupOnFail @@ -353,6 +355,7 @@ func (r *Runner) Rollback(hr v2.HelmRelease) error { rollback := action.NewRollback(r.config) rollback.Timeout = hr.Spec.GetRollback().GetTimeout(hr.GetTimeout()).Duration rollback.Wait = !hr.Spec.GetRollback().DisableWait + rollback.WaitForJobs = !hr.Spec.GetRollback().DisableWaitForJobs rollback.DisableHooks = hr.Spec.GetRollback().DisableHooks rollback.Force = hr.Spec.GetRollback().Force rollback.Recreate = hr.Spec.GetRollback().Recreate