<p>I have a scenario like below,
Have two releases - Release-A and Release-B.</p>
<p>Currently, I am on Release-A and need an upgrade of all the microservices to Release-B.
I tried performing the helm upgrade of microservice - &quot;mymicroservice&quot; with the below command to deliver Release-B.</p>
<pre><code>helm --kubeconfig /home/config upgrade --namespace testing --install --wait mymicroservice mymicroservice-release-b.tgz
</code></pre>
<p>Because of some issue, the deployment object got failed to install and went into an error state.</p>
<p>Observing this, I perform the below rollback command.</p>
<pre><code>helm --kubeconfig /home/config --namespace testing rollback mymicroservice
</code></pre>
<p>Due to some issue(may be an intermittent system failure or user behavior), the Release-A's deployment object also went into failed/Crashloopbackoff state.Although this will result in helm rollback success, the deployment object is still not entered the running state.</p>
<p>Once I made the necessary corrections, I will retry the rollback. As the deployment spec is already updated with helm, it never attempts to re-install the deployment objects even if it is in the failed state.</p>
<p>Is there any option with Helm to handle the above scenarios ?.</p>
<p>Tried with <code>--force</code> flag, but there are other errors related to Service object replace in the microservice when used the --force flag approach.</p>
<pre><code>Rollback &quot;mymicroservice -monitoring&quot; failed: failed to replace object: Service &quot;mymicroservice-monitoring&quot; is invalid: spec.clusterIP: Invalid value: &quot;&quot;: field is immutable
</code></pre>

<p>Maybe this can help u out:</p>
<ul>
<li>Always use the helm <strong>upgrade --install</strong> command. I've seen you're using so you're doing well. This installs the charts if they're not present and upgrades them if they're present.</li>
<li>Use --atomic flag to rollback changes in the event of a failed operation during helm upgrade.</li>
<li>And the flag --cleanup-on-fail: It allows that Helm deletes newly created resources during a rollback in case the rollback fails.</li>
</ul>
<p>From doc:</p>
<p>--atomic: if set, upgrade process rolls back changes made in case of failed upgrade. The --wait flag will be set automatically if --atomic is used</p>
<p>--cleanup-on-fail allow deletion of new resources created in this upgrade when upgrade fails</p>
<p>There are cases where an upgrade creates a resource that was not present in the last release. Setting this flag allows Helm to remove those new resources if the release fails. The default is to not remove them (Helm tends to avoid destruction-as-default, and give users explicit control over this)</p>
<p><a href="https://helm.sh/docs/helm/helm_upgrade/" rel="noreferrer">https://helm.sh/docs/helm/helm_upgrade/</a></p>
