Skip to content
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

Fail to decode yaml that has affinity with versions v3.9.x #3523

Closed
emailbob opened this issue Feb 1, 2021 · 3 comments
Closed

Fail to decode yaml that has affinity with versions v3.9.x #3523

emailbob opened this issue Feb 1, 2021 · 3 comments
Labels
area/kyaml issues for kyaml area/plugin issues for plugins kind/bug Categorizes issue or PR as related to a bug.

Comments

@emailbob
Copy link

emailbob commented Feb 1, 2021

Describe the bug

Since kustomize 3.9.x when kustomize changed the way it manipulates YAML using the kyaml module I started getting this error

2021/02/01 16:46:53 failed to decode ynode: yaml: unmarshal errors: line 97: mapping key "affinity" already defined at line 30

When using the built in HelmChartInflationGenerator if the Helm values file has two affinities set for example


  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: component
                operator: In
                values:
                  - server
              - key: app
                operator: In
                values:
                  - prometheus
          topologyKey: "kubernetes.io/hostname"
...
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: component
                operator: In
                values:
                  - alertmanager
              - key: app
                operator: In
                values:
                  - prometheus
          topologyKey: "kubernetes.io/hostname"

It will throw an error

If they are empty and set like this

affinity: {}
...
affinity: {}

It will work

Expected output

No error

Actual output

2021/02/01 16:46:53 failed to decode ynode: yaml: unmarshal errors:
  line 97: mapping key "affinity" already defined at line 30

Kustomize version

v3.9.1 and v3.9.2

Platform

All

Additional context

I rolled back to v3.8.9 and that version works

@Shell32-Natsu Shell32-Natsu added area/kyaml issues for kyaml area/plugin issues for plugins kind/bug Categorizes issue or PR as related to a bug. labels Feb 1, 2021
@Shell32-Natsu
Copy link
Contributor

I believe this error is thrown by go-yaml. I suppose that a valid YAML file shouldn't have duplicate keys.

@rochacon
Copy link

Seems like this is a duplicate of #3480

@Shell32-Natsu
Copy link
Contributor

@rochacon Thanks for pointing out. It's duplicate.

Duplicate of #3480

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kyaml issues for kyaml area/plugin issues for plugins kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants