Open lucinvitae opened 4 years ago
Also, as an alternative or precursor to better error handling, perhaps it would be useful to add some documentation in a troubleshooting guide for sync issues about how duplicate keys can block syncs. (happy to help do this if pointed to the right doc)
I suffered from this issue and took a whole day to figure out the reason. the description of this issue was very informative and I hope the comparison error message to be more understandable.
This thread saved me a few years of my life.. wasted 2 days trying to figure out why argo won't sync. +1 on this issue
I'm going to ask someone to at least update the FAQ. Hopefully we can do that this week. Maybe we'll also write a PR to fix the error reporting.
For the morbidly curious, the error message comes from: https://github.com/kubernetes/apimachinery/blob/b4dea92b265131dae13c1e9ebb0a31821bf5daf8/pkg/util/strategicpatch/patch.go#L1019
I really can't figure out what in ArgoCD triggers that.
Summary
Improve error handling for
ComparisonError
failures that are due to a change in a map which introduces duplicate keysMotivation
Having duplicate keys in a mapping (e.g. a Helm chart which templates the
env:
setting for a Kubernetes container) causes ArgoCD syncs to fail withComparisonError
errors that appear as follows:Here's a full example from a recent deployment issue our team faced:
The app may be in a healthy status, with “Sync OK” message for each sync, but the section in the ArgoCD UI that shows whether the app is up to date with the repo shows
Unknown
when this happens.This error message can be quite misleading, suggesting the order is invalid. In our case, due to many in-flight changes and the inability to identify which change was causing the failure, our team was manually deleting and recreating a deployment for over a week to work around the error before spotting the duplicate keys and resolving the sync issue.
Here is a section of our helm chart (modified for brevity) containing the original bug with duplicate keys, for reference:
(See how
.Values.worker.env
is included twice)See this thread in the ArgoCD Slack channel for more info: https://argoproj.slack.com/archives/CASHNF6MS/p1596812671404600
Proposal
The message could read something more informative, like
duplicate keys in mapping is blocking ability to compare/diff configs
instead. This would point developers immediately to duplication as the root cause, instead of trying to decipher the order of keys in a long list.