helm error when updating: UPGRADE FAILED: The order in patch list
Asked Answered
O

6

33

I have a problem with helm deployment. It has happend after I have added a new environment variable to the deployment.

When I execute: helm upgrade [RELEASE] [CHART]

I get the following error:

Error: The order in patch list:
[
    map[name:APP_ENV value:prod]
    map[name:MAILER_URL value:...] 
    map[name:APP_VERSION value:v0-0-3] 
    map[name:APP_COMMIT_SHA value:...]
]
 doesn't match $setElementOrder list:
[
    map[name:APP_ENV] 
    map[name:COMPOSER_HOME] 
    map[name:PHP_XDEBUG_ENABLED] 
    map[name:DATABASE_DRIVER] 
    map[name:DATABASE_HOST] 
    map[name:DATABASE_NAME] 
    map[name:DATABASE_USER] 
    map[name:SECRET] 
    map[name:INDEX_HOSTS]
    map[name:MAILER_FROM_ADDRESS] 
    map[name:MAILER_FROM_NAME] 
    map[name:UPLOAD_DIR] 
    map[name:ARCHIVE_DIR] 
    map[name:CATALOG_STORAGE_DIR] 
    map[name:ASSET_STORAGE_DIR] 
    map[name:TMP_STORAGE_DIR] 
    map[name:UPLOAD_TMP_DIR] 
    map[name:APP_VERSION] 
    map[name:APP_COMMIT_SHA] 
    map[name:APP_CRON] 
    map[name:DATABASE_PASSWORD] 
    map[name:MAILER_URL]
    ...
]

However, if I execute the same command with the flag --dry-run, I do not get any error ( helm upgrade [RELEASE] [CHART] --dry-run)

I don't know the reason of this problem or how to solve it

Ornithine answered 17/3, 2020 at 17:14 Comment(3)
Could you please run helm lint to check if there are any issues with the helm chart? I am analyzing your problem in a meantime.Incoherence
Also your MAILER_URL value should be put after the APP_COMMIT_SHA value. Could you reorder them and tell me if that helped?Incoherence
The result of helm lint: Chart.yaml: icon is recommended 1 chart(s) linted, no failuresOrnithine
O
53

I've found that the reason of this problem was that I had some envVars duplicated. In my deployment I had:

...
spec:
  template:
    spec:
      container:
        env:
        - name:  ENV_VAR_NAME
          value: "test"
        - name:  ENV_VAR_NAME
          value: "test"
...

After removing the duplicated variable:

...
spec:
  template:
    spec:
      container:
        env:
        - name:  ENV_VAR_NAME
          value: "test"
...

The helm upgrade [RELEASE] [CHART] worked fine

Ornithine answered 18/3, 2020 at 10:33 Comment(1)
some more context here: github.com/helm/helm/issues/6002Coordinate
H
3

I had the same error, but no duplicate env variable. I forced the update by doing:

helm upgrade [RELEASE] [CHART] --force
Handshake answered 22/4, 2021 at 8:8 Comment(1)
In my case it was because the same environment variable was being set via Helm chart template value interpolation.Counterproof
I
2

I had the same error but no duplicate variables. Reordering the env vars alphabetically worked for me :-(

Insurrection answered 1/12, 2021 at 15:50 Comment(0)
I
1

All the answers are correct, I just wanted to add the reason for that - basically, Kubernetes is failing to detect changes between the two versions of the YAML (deployed and new) thus failing to update.


So basically what you can do is delete and re-deploy a new version overriding everything - I had this issue, in a non-productive environment that I could handle deleting and re-deploying.

Another more "production-friendly" fix (avoiding downtime), already mentioned in other replies is to help Kubernetes find the differences, remove duplicate values, and match the order of the keys of the deployed YAML file.

Issus answered 3/4 at 18:20 Comment(0)
K
0

I know it's an old post with an accepted answer, but I'd like to answer the people that reached this post and didn't find duplicate variables, just like me.

If you pass the --reuse-values values flag, you might find this issue too, because helm will reuse the previous values and when a variable changes, instead of replacing, helm might append the variable to the list which in the end leads to the duplicate variable and finally throws the same error.

The workaround is to simply run without the flag.

Korean answered 14/10, 2023 at 16:52 Comment(0)
S
-1

I got the same error fixed via remove duplicated variable.

Stutsman answered 7/6, 2023 at 5:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.