# Helm Release.IsInstall and IsUpgrade are inaccurate

**URL:** <https://community.replicated.com/t/helm-release-isinstall-and-isupgrade-are-inaccurate/1189>\
**Category:** Packaging an application\
**Tags:** kots\
**Created:** [April 18, 2023, 5:36am UTC](https://community.replicated.com/t/helm-release-isinstall-and-isupgrade-are-inaccurate/1189 "2023-04-18T05:36:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anyweez](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/anyweez/32/544_2.png) [@anyweez](https://community.replicated.com/u/anyweez)\
**Post date:** [April 18, 2023, 5:36am UTC](https://community.replicated.com/t/helm-release-isinstall-and-isupgrade-are-inaccurate/1189/1 "2023-04-18T05:36:01Z")

</div>

I’m installing a Helm chart via KOTS and trying to add some logic that depends on whether it’s running an initial install or upgrade. Helm’s IsInstall and IsUpgrade values are always set to true and false, respectively, when I install via KOTS though it works as expected when I install via Helm directly.

To test a few permutations, I added some annotations and saw that these values never varied when installing and upgrading via kots:

```auto
  annotations:
    test.io/is-install: {{ $.Release.IsInstall | quote }} # always `true` with kots
    test.io/is-upgrade: {{ $.Release.IsUpgrade | quote }} # always `false` with kots

```

Is this expected? I would expect the behavior to be identical to Helm.

---

<div class="post-metadata">

**Author:** ![anyweez](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/anyweez/32/544_2.png) [@anyweez](https://community.replicated.com/u/anyweez)\
**Post date:** [April 18, 2023, 6:20am UTC](https://community.replicated.com/t/helm-release-isinstall-and-isupgrade-are-inaccurate/1189/2 "2023-04-18T06:20:22Z")

</div>

Specifically, I’m trying to find a way to generate a random password at initial install and not overwrite it during later updates – the password is stored in a k8s secret. I’d appreciate a workaround for this that doesn’t depend on the IsInstall / IsUpgrade values if you anyone has recommendations.

My understanding from elsewhere is that the most common methods, including using `lookup`, [aren’t supported](https://community.replicated.com/t/is-the-helm-lookup-function-supported/1060) due to how Replicated works internally.

---

<div class="post-metadata">

**Author:** ![craig](https://avatars.discourse-cdn.com/v4/letter/c/ed8c4c/32.png) [@craig](https://community.replicated.com/u/craig)\
**Post date:** [April 24, 2023, 3:01pm UTC](https://community.replicated.com/t/helm-release-isinstall-and-isupgrade-are-inaccurate/1189/3 "2023-04-24T15:01:28Z")

</div>

The values for `.Release.IsInstall` and `.Release.IsUpgrade` will always be `true` and `false` respectively because KOTS runs a `helm template` on the chart before installing so that additional kustomize patches can be applied to the generated resources (pull secrets, image re-writes, etc). The kustomize output is then installed with `helm upgrade -i`, but by that point, those template functions have already been rendered.

Here is some more information about how the `.Release` object will behave in KOTS when using native Helm:

- `.Release.IsInstall` - always `true`
- `.Release.IsUpgrade` - always `false`
- `.Release.Name` - the HelmChart resource `spec.chart.releaseName` or `spec.chart.name` if a release name is not specified
- `.Release.Namespace` - the HelmChart resource `spec.namespace` or the admin console namespace if one is not specified
- `.Release.Revision` - always `1`
- `.Release.Service` - always `Helm`

---

<div class="post-metadata">

**Author:** ![Vitaliy](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/vitaliy/32/763_2.png) [@Vitaliy](https://community.replicated.com/u/Vitaliy)\
**Post date:** [May 12, 2023, 2:59pm UTC](https://community.replicated.com/t/helm-release-isinstall-and-isupgrade-are-inaccurate/1189/4 "2023-05-12T14:59:10Z")

</div>

> [@craig](#):
>
> `Release.Revision - always 1`

Does it means that before upgrade of application performed `helm uninstall`? I saw this in logs of kotsadm.log.

```auto
{"level":"info","ts":"2023-05-12T12:53:56Z","msg":"running helm with arguments [uninstall my-app -n default]"}
{"level":"info","ts":"2023-05-12T12:53:57Z","msg":"stdout (helm uninstall) = release \"my-app\" uninstalled\n"}
{"level":"info","ts":"2023-05-12T12:53:57Z","msg":"stderr (helm uninstall) = "}

```

What exactly happening when you press ‘Deploy’ button agains new version of application? Currently my pre-upgrade hooks stop working and I don’t get why.
