Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
release: support retrying rollbacks
Browse files Browse the repository at this point in the history
This commit adds support for retrying rollbacks using
`.spec.rollback.retry` until the configured `.spec.rolback.maxRetries`
count is reached (defaults to 5, setting it to 0 means infinite). The
reset of the counter happens after a successful upgrade or a change
(e.g. chart change, `.spec` change).

This makes it possible to for example recover from transient errors
that were the cause of the rollback, and not a persistent chart or
values failure.
  • Loading branch information
hiddeco committed Jan 27, 2020
1 parent 63f9ace commit e894be6
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 42 deletions.
9 changes: 9 additions & 0 deletions chart/helm-operator/templates/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ spec:
enable:
description: If set, will perform rollbacks for this release on upgrade failures
type: boolean
retry:
description: If set, the upgrade of a rolled back release will be retried until
the maximum amount of retries is reached
type: boolean
maxRetries:
description: The maximum amount of retries that should be attempted for a rolled
back release if retries are enabled, defaults to 5, 0 equals infinite
type: integer
format: int64
force:
description: If set, will force resource update through delete/recreate if needed
type: boolean
Expand Down
9 changes: 9 additions & 0 deletions deploy/flux-helm-release-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ spec:
enable:
description: If set, will perform rollbacks for this release on upgrade failures
type: boolean
retry:
description: If set, the upgrade of a rolled back release will be retried until
the maximum amount of retries is reached
type: boolean
maxRetries:
description: The maximum amount of retries that should be attempted for a rolled
back release if retries are enabled, defaults to 5, 0 equals infinite
type: integer
format: int64
force:
description: If set, will force resource update through delete/recreate if needed
type: boolean
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/helm.fluxcd.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ func (s RepoChartSource) CleanRepoURL() string {

type Rollback struct {
Enable bool `json:"enable,omitempty"`
Retry bool `json:"retry,omitempty"`
MaxRetries *int64 `json:"maxRetries,omitempty"`
Force bool `json:"force,omitempty"`
Recreate bool `json:"recreate,omitempty"`
DisableHooks bool `json:"disableHooks,omitempty"`
Expand All @@ -178,6 +180,13 @@ func (r Rollback) GetTimeout() time.Duration {
return time.Duration(*r.Timeout) * time.Second
}

func (r Rollback) GetMaxRetries() int64 {
if r.MaxRetries == nil {
return 5
}
return *r.MaxRetries
}

// HelmReleaseSpec is the spec for a HelmRelease resource
type HelmReleaseSpec struct {
ChartSource `json:"chart"`
Expand Down Expand Up @@ -268,6 +277,11 @@ type HelmReleaseStatus struct {
// +optional
Revision string `json:"revision,omitempty"`

// RollbackCount defines the amount of rollback attempts made,
// it is incremented after a rollback failure and reset after a
// successful upgrade or revision change.
RollbackCount int64 `json:"retryCount,omitempty"`

// Conditions contains observations of the resource's state, e.g.,
// has the chart which it refers to been fetched.
// +optional
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/helm.fluxcd.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/install/generated_templates.gogen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions pkg/install/templates/flux-helm-release-crd.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ spec:
enable:
description: If set, will perform rollbacks for this release on upgrade failures
type: boolean
retry:
description: If set, the upgrade of a rolled back release will be retried until
the maximum amount of retries is reached
type: boolean
maxRetries:
description: The maximum amount of retries that should be attempted for a rolled
back release if retries are enabled, defaults to 5, 0 equals infinite
type: integer
format: int64
force:
description: If set, will force resource update through delete/recreate if needed
type: boolean
Expand Down
Loading

0 comments on commit e894be6

Please sign in to comment.