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

Commit

Permalink
release: disable atomic flag for initial install (#256)
Browse files Browse the repository at this point in the history
release: disable atomic flag for initial install
  • Loading branch information
hiddeco authored Jan 29, 2020
2 parents d1efa70 + f207fff commit f31bd47
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions pkg/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,20 +202,29 @@ func (r *Release) Sync(client helm.Client, hr *v1.HelmRelease) (rHr *v1.HelmRele
Force: hr.Spec.ForceUpgrade,
ResetValues: hr.Spec.ResetValues,
MaxHistory: hr.GetMaxHistory(),
// We only set this during installation to delete a failed
// release, but not during upgrades, as we ourselves want
// to be in control of rollbacks.
Atomic: curRel == nil,
Wait: hr.Spec.Wait || hr.Spec.Rollback.Enable,
Wait: hr.Spec.Wait || (curRel != nil && hr.Spec.Rollback.Enable),
})
if err != nil {
_ = status.SetCondition(r.helmReleaseClient.HelmReleases(hr.Namespace), hr, status.NewCondition(
v1.HelmReleaseReleased, corev1.ConditionFalse, failReason, err.Error()))
logger.Log("error", "Helm release failed", "revision", revision, "err", err.Error())

// If this is the first release, or rollbacks are not enabled;
// return and wait for the next signal to retry...
if curRel == nil || !hr.Spec.Rollback.Enable {
// If there was no release prior to this,
// uninstall the failed release so it can be retried.
if curRel == nil {
logger.Log("info", "uninstalling initial failed release so it can be retried")
if uErr := client.Uninstall(hr.GetReleaseName(), helm.UninstallOptions{
Namespace: hr.GetTargetNamespace(),
KeepHistory: false,
Timeout: hr.GetTimeout(),
}); uErr != nil {
logger.Log("error", "Helm uninstall failed", "err", uErr.Error())
}
return hr, err
}

// Rollbacks are not enabled; return and wait for the next signal to retry...
if !hr.Spec.Rollback.Enable {
return hr, err
}

Expand Down Expand Up @@ -289,6 +298,7 @@ func (r *Release) Uninstall(client helm.Client, hr *v1.HelmRelease) {
if err := client.Uninstall(hr.GetReleaseName(), helm.UninstallOptions{
Namespace: hr.GetTargetNamespace(),
KeepHistory: false,
Timeout: hr.GetTimeout(),
}); err != nil {
logger.Log("error", "failed to uninstall Helm release", "err", err.Error())
}
Expand Down

0 comments on commit f31bd47

Please sign in to comment.