-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kyaml panics on duplicate keys #3480
Comments
These are the lines that need to be changed: Line 791 in 550a892
Line 799 in 550a892
@SyamSundarKirubakaran would you like to pick this up? We should also look for anywhere else we log Fatal |
// Map ...
// Use MapOrDie to log.Fatal on error
func (rn *RNode) Map() (map[string]interface{}, error) {
...
return fmt.Errorf(...)
}
func (rn *RNode) MapOrDie() map[string]interface{} {
m, err := rn.Map()
if err != nil {
log.Fatal(err)
}
return m
} |
Also: go-yaml/yaml#623 |
This is fixed and will be available in the next release |
When will the next release be shipped? We're currently running into this issue where an upstream chart we use has duplicate keys and hasn't fixed it yet, and kustomize is crashing when we're trying to alter things. |
@trynity what version of kustomize are you using? |
@natasha41575 4.0.5 |
@trynity I would expect 4.0.5 to have this issue fixed (there is a regression test here) Would you be able to provide a set of files that can reproduce the issue you are having? Kustomize 4.1.0 was also released yesterday and you can try it. |
@natasha41575 is there any way the kustomize tool can ignore the duplicate keys? Because I have written a script to patch yamls from helm charts which has duplicate keys, and because of that my script breaks every single time. Also, version v4.0.5 can show the user where is the error when there are hundreds of manifest as resources. The latest Kustomize version does not show the user where is the error when there are hundreds of manifest as resources. |
@bhagyesh18 We can improve the error to show where it is. I'm not sure that we can ignore the duplicate keys entirely. The error comes from an imported yaml library. I will do some investigation but I'm not sure that we can work around it. |
Flux complains with the following error:
In the project there is no indication of such issue in any directory/file For example if I create such duplication, I can see the error: When checking with |
I also have a CustomResourceDefinitions file that doesn't appear to have duplicate keys, but kustomize build fails on it. This looks like a spurious error and I believe there is still a bug here, though I can't offer much more help than that, I do have a repo which reproduces it: https://github.com/kingdonb/bb-csh-flux Running
The CRDs file is from https://charts.okteto.com/crds.yaml (which comes from the instructions at https://okteto.com/docs/enterprise/install/deployment/ ) An example of the section that the parser is tripping over, (around line 40-46): These don't look like duplicate hash keys to me, they are just neighboring mappings in the (Let me know if I should open a separate issue for this!) |
Beg pardon, I was still using an old Kustomize 3.9.3 The error persists and is very similar in Kustomize 4.2.0 though:
For reference, this is a common CRD from cert-manager:
If I swap out the CRD for cert-manager 1.4.0 CRDs, I no longer get this error. It still seems like a bug, but maybe I don't know how to read CRD and it really is a duplicate key based on some logic I don't understand. (Still based on @haim-ari report and my own experience, I think that a bug remains here.) |
In Flux v2 we decided to use kustomize libraries in our controllers and we make extensive use of
kyaml
. We found that if a manifest contains duplicate keys, kyaml panics taking down the whole controller.Can we please not panic and instead return an error from kyaml containing the manifest name so that both Kustomize and Flux users can track down which object/manifest caused this? Without a hint to the invalid manifest, there is no way for users that have hundreds of manifests in a single kustomization to debug such errors.
Example:
kustomization.yaml
resources.yaml
Actual output
Kustomize version
The text was updated successfully, but these errors were encountered: