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

patchesJson6902 with operation "move" fail under certain circumstances. #3178

Closed
sanposhiho opened this issue Nov 4, 2020 · 3 comments
Closed
Labels
area/plugin issues for plugins kind/bug Categorizes issue or PR as related to a bug.

Comments

@sanposhiho
Copy link
Member

sanposhiho commented Nov 4, 2020

Hi :)

Describe the bug

  • use patchesJson6902 with operation move
  • move /metadata/name
  • patchesJson6902 has several targets
  • several targets has same group, target, and kind

When use the above resource from other kustomization.yaml with resources statements, the following errors occur

Error: accumulating resources: accumulateFile "accumulating resources from '../jobs/': '~/workspace/sample/jobs' must resolve to a file", accumulateDirector: "recursed merging from path '~/workspace/sample/jobs': may not add resource with an already registered id: batch_v1_Job|~X|~N"

Files that can reproduce the issue

https://github.com/sanposhiho/kustomize-jsonpatches-bug-sample

$ kustomize build jobs/
apiVersion: batch/v1
kind: Job
metadata:
  generateName: hogehoge
spec:
  template:
    spec:
      containers:
      - image: hoge:latest
        name: hogehoge
---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: fugafuga
spec:
  template:
    spec:
      containers:
      - image: fuga:latest
        name: fugafuga

$ kustomize build api
Error: accumulating resources: accumulateFile "accumulating resources from '../jobs/': '~/workspace/sample/jobs' must resolve to a file", accumulateDirector: "recursed merging from path '~/workspace/sample/jobs': may not add resource with an already registered id: batch_v1_Job|~X|~N"

Expected output

$ kustomize build api/
apiVersion: batch/v1
kind: Job
metadata:
  generateName: hogehoge
spec:
  template:
    spec:
      containers:
      - image: hoge:latest
        name: hogehoge
---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: fugafuga
spec:
  template:
    spec:
      containers:
      - image: fuga:latest
        name: fugafuga

Actual output

$ kustomize build api
Error: accumulating resources: accumulateFile "accumulating resources from '../jobs/': '~/workspace/sample/jobs' must resolve to a file", accumulateDirector: "recursed merging from path '~/workspace/sample/jobs': may not add resource with an already registered id: batch_v1_Job|~X|~N"

Kustomize version

$ kustomize version
{Version:kustomize/v3.8.5 GitCommit:4052cd4fd8c76a17b5f64e32509f3fba9713fe75 BuildDate:2020-10-08T05:35:40+01:00 GoOs:darwin GoArch:amd64}

Platform

macOS

@Shell32-Natsu
Copy link
Contributor

I cannot reproduce this issue. Looks like you should update the paths you used in the patch. Since you have a / in the field name so you need to replace it by ~1 in json patch path.

@Shell32-Natsu Shell32-Natsu added area/plugin issues for plugins kind/bug Categorizes issue or PR as related to a bug. triage/not-reproducible Indicates an issue can not be reproduced as described. labels Nov 4, 2020
@sanposhiho
Copy link
Member Author

Sorry, I forgot to commit my latest sample.
Please check again as I've updated the sample.

@Shell32-Natsu
Copy link
Contributor

After your json patch, 2 resources don't have /metadata/name field. And in the overlay, these 2 resources are needed to be added to the resource list. This causes problem, because these 2 resources now have identical ID batch_v1_Job|~X|~N.

@Shell32-Natsu Shell32-Natsu removed the triage/not-reproducible Indicates an issue can not be reproduced as described. label Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

2 participants