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

Kustomize "multiple matches" failure since kustomize/v3.9.2 #3489

Closed
sylr opened this issue Jan 20, 2021 · 5 comments · Fixed by #3529
Closed

Kustomize "multiple matches" failure since kustomize/v3.9.2 #3489

sylr opened this issue Jan 20, 2021 · 5 comments · Fixed by #3529
Assignees
Labels
area/api issues for api module kind/bug Categorizes issue or PR as related to a bug. triage/unresolved Indicates an issue that can not or will not be resolved.

Comments

@sylr
Copy link
Contributor

sylr commented Jan 20, 2021

Describe the bug

Kustomize workspace which was working up until kustomize/v3.9.1 now fails with and without kyaml.

$ ~/go/src/sigs.k8s.io/kustomize/kustomize/kustomize build --enable_kyaml=false .
Error: obj '{"apiVersion": "rbac.authorization.k8s.io/v1", "kind": "ClusterRoleBinding", "metadata": {
    "annotations": {"config.kubernetes.io/originalNs": "default"}, "labels": {"app": "external-dns",
      "instance": "public"}, "name": "external-dns-viewer"}, "roleRef": {"apiGroup": "rbac.authorization.k8s.io",
    "kind": "ClusterRole", "name": "external-dns"}, "subjects": [{"kind": "ServiceAccount",
      "name": "external-dns"}]}
' at path 'subjects': multiple matches for ~G_v1_ServiceAccount|default|external-dns:
  [~G_v1_ServiceAccount|kube-system|external-dns
 ~G_v1_ServiceAccount|kube-system|external-dns-private
]
$ ~/go/src/sigs.k8s.io/kustomize/kustomize/kustomize build  .
Error: obj 'apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: external-dns-viewer
  labels:
    app: external-dns
    instance: public
  annotations:
    config.kubernetes.io/originalNs: default
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: external-dns
subjects:
- kind: ServiceAccount
  name: external-dns
' at path 'subjects': multiple matches for ~G_v1_ServiceAccount|default|external-dns:
  [~G_v1_ServiceAccount|kube-system|external-dns
 ~G_v1_ServiceAccount|kube-system|external-dns-private
]

Files that can reproduce the issue

https://github.com/sylr/kustomize-crash-reproduction

@sylr
Copy link
Contributor Author

sylr commented Jan 20, 2021

I did a bisect and it seems bb41d01 is responsible for this problem.

$ git bisect start
$ git bisect good kustomize/v3.9.1
$ git bisect bad kustomize/v3.9.2
Bisecting: 40 revisions left to test after this (roughly 5 steps)
[7c6bf2e21d30a3dcde0a627ba24f636381a5408b] When merging configmaps, retain proper quoting.
$ git bisect run ./bisect.sh
...
bb41d018b5350c24031bace975d7b735d26b7b9b is the first bad commit
commit bb41d018b5350c24031bace975d7b735d26b7b9b
Author: monopole <jeff.regan@gmail.com>
Date:   Wed Jan 13 13:03:22 2021 -0800

    Add more tests and explain some strange quotes.

 api/internal/target/kusttarget_test.go             |  4 +-
 api/krusty/basic_io_test.go                        | 67 +++++++++++++++++++++-
 api/krusty/configmaps_test.go                      |  8 ---
 api/krusty/kustomizer.go                           |  5 +-
 api/krusty/variableref_test.go                     | 34 +++++++----
 api/resmap/resmap.go                               |  3 +-
 api/resmap/reswrangler.go                          |  8 +--
 api/resmap/reswrangler_test.go                     |  4 +-
 api/resource/resource.go                           | 64 +++++----------------
 api/testutils/kusttest/harness.go                  |  5 +-
 .../PrefixSuffixTransformer_test.go                |  1 -
 11 files changed, 111 insertions(+), 92 deletions(-)
bisect run success

@Shell32-Natsu Shell32-Natsu added area/api issues for api module area/kyaml issues for kyaml kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 20, 2021
@sylr
Copy link
Contributor Author

sylr commented Jan 21, 2021

@Shell32-Natsu you tagged this area/kyaml but this problem is also occuring when kyaml is disabled.

@Shell32-Natsu
Copy link
Contributor

I tagged this from my guess. Need to investigate more.

@Shell32-Natsu
Copy link
Contributor

This is because the reference in subjects field in base/external-dns/clusterrolebinding.yml is using original ID. When kustomize is doing a step named name reference update, it will try to find find the resources that have the original ID and update the reference to the resource's current ID. Note that this step is done after all layers have been processed so there will be 2 resources that have the same original ID in your example.

@Shell32-Natsu Shell32-Natsu added triage/unresolved Indicates an issue that can not or will not be resolved. and removed area/kyaml issues for kyaml needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 21, 2021
@monopole monopole self-assigned this Jan 28, 2021
ymmt2005 added a commit to cybozu/neco-containers that referenced this issue Feb 2, 2021
ymmt2005 added a commit to cybozu/neco-containers that referenced this issue Feb 2, 2021
ymmt2005 added a commit to cybozu-go/neco that referenced this issue Feb 2, 2021
kustomize 3.9.2 has a critical bug to us.
kubernetes-sigs/kustomize#3489
This was referenced Feb 3, 2021
@monopole
Copy link
Contributor

monopole commented Feb 3, 2021

@sylr If you have time, please take a look at TestIssue3489 in api/krusty/namereference_test.go in #3529

It purports to cover https://github.com/sylr/kustomize-crash-reproduction

Thanks for the report. This will go out in release 3.9.3 this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api issues for api module kind/bug Categorizes issue or PR as related to a bug. triage/unresolved Indicates an issue that can not or will not be resolved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants