<p>In my cluster Im using <a href="https://github.com/fluxcd/flux" rel="nofollow noreferrer">weave flux</a> along with their flux-helm-operator to manage my cluster the gitops way.</p>

<p>However, when I make a change to the chart at flux git repository, I often come across the following error msg:</p>

<pre><code>ts=2019-09-25T11:54:37.604506452Z caller=chartsync.go:328 component=chartsync
warning="unable to proceed with release" 
resource=mychart:helmrelease/mychart release=mychart
err="release requires a rollback before it can be upgraded (FAILED)"
</code></pre>

<p>Im not sure what does it mean in helm, but anyway, I am not supposed to run any helm command since the releases are managed by flux so I am wondering what is the correct way to deal with this error on production</p>

<p>(besides deleting the release and waiting for flux to recreate it)</p>

<p>A well-explained answer will be very much accepted, Thanks.</p>

Efrat Levitan
<h1>Let's dive into the code of <a href="https://github.com/fluxcd/helm-operator" rel="nofollow noreferrer"><code>helm-operator</code></a></h1>

<p>Warning <code>unable to proceed with release</code> arises after <a href="https://github.com/fluxcd/helm-operator/blob/801c64c5fde1e0aa228e5012f2f9514311bff6a9/pkg/chartsync/chartsync.go#L325" rel="nofollow noreferrer"><code>GetUpgradableRelease</code></a></p>

<blockquote>
<pre><code>    // GetUpgradableRelease returns a release if the current state of it
    // allows an upgrade, a descriptive error if it is not allowed, or
    // nil if the release does not exist.
</code></pre>
</blockquote>

<p>It returns error <code>release requires a rollback before it can be upgraded</code> if release has <code>Status_FAILED</code> state (see <a href="https://github.com/fluxcd/helm-operator/blob/68b5f64c1ba2a4859581a82fa6b16bbc313c02f6/pkg/release/release.go#L89" rel="nofollow noreferrer">release.go#89</a> )</p>

<h1><code>UNHEALTHY</code> state blocks release</h1>

<p>As <code>flux</code> developers <a href="https://github.com/fluxcd/flux/issues/2265" rel="nofollow noreferrer">mentioned in #2265</a>, there is no way to roll to <code>UNHEALTHY</code> state.</p>

<blockquote>
  <p>This is not a bug but I can see where your expectation is coming from.</p>
  
  <p>Flux will only move healthy releases forward, one of the reasons for this is to ensure we do not end up in a loop of failure, the <code>--force</code> flag is thus not intended to be used to force the upgrade of an unhealthy resource (you should use the <a href="https://github.com/fluxcd/flux/blob/8292179855e15370fb3d3b03135a61b54f00ae42/site/helm-integration.md#rollbacks" rel="nofollow noreferrer">rollback feature</a> for this) but was developed to make it possible to upgrade charts with e.g. backwards incompatible changes (changes on immutable fields for example, which require a resource to be removed first, see <a href="https://github.com/fluxcd/flux/pull/1760" rel="nofollow noreferrer">#1760</a>).</p>
  
  <p><strong>Conclusion:</strong> the <code>forceUpgrade</code> is honoured, but can not be used to force the upgrade of a release in an <code>UNHEALTHY</code> state. </p>
</blockquote>

<h1><a href="https://github.com/fluxcd/flux/blob/8292179855e15370fb3d3b03135a61b54f00ae42/site/helm-integration.md#rollbacks" rel="nofollow noreferrer">Rollback</a></h1>

<p>As author recommends, you should use <a href="https://github.com/fluxcd/flux/blob/8292179855e15370fb3d3b03135a61b54f00ae42/site/helm-integration.md#rollbacks" rel="nofollow noreferrer"><code>rollback</code></a> feature</p>

<blockquote>
  <p>From time to time a release made by the Helm operator may fail, it is possible to automate the rollback of a failed release by setting <code>.spec.rollback.enable</code> to true on the HelmRelease resource.</p>

<pre><code>Note: a successful rollback of a Helm chart containing a StatefulSet resource is known to be tricky, and one of the main reasons automated rollbacks are not enabled by default for all HelmReleases. Verify a manual rollback of your Helm chart does not cause any problems before enabling it.
</code></pre>
  
  <p>When enabled, the Helm operator will detect a faulty upgrade and perform a rollback, it will not attempt a new upgrade unless it detects a change in values and/or the chart.</p>
</blockquote>

<pre><code>apiVersion: flux.weave.works/v1beta1
kind: HelmRelease
# metadata: ...
spec:
  # Listed values are the defaults.
  rollback:
    # If set, will perform rollbacks for this release.
    enable: false
    # If set, will force resource update through delete/recreate if
    # needed.
    force: false
    # Prevent hooks from running during rollback.
    disableHooks: false
    # Time in seconds to wait for any individual Kubernetes operation.
    timeout: 300
    # If set, will wait until all Pods, PVCs, Services, and minimum
    # number of Pods of a Deployment are in a ready state before
    # marking the release as successful. It will wait for as long
    # as the set timeout.
    wait: false
</code></pre>
