kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations
Apache License 2.0
11.02k stars 2.25k forks source link

Local reference to temporary directory fails build on Mac #5752

Open Stef16Robbe opened 2 months ago

Stef16Robbe commented 2 months ago

What happened?

I added this local reference in my Kustomize file (MacOS):

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../../../var/folders/2b/ryb_dw7j1gg183b46_ppt5sr0000gn/T/folder

It is a relative path towards /var/folders/2b/ryb_dw7j1gg183b46_ppt5sr0000gn/T/folder, which exists, and contains a Kustomize file that builds successfully on it's own (using kustomize build "../../../../../var/folders/2b/ryb_dw7j1gg183b46_ppt5sr0000gn/T/folder" works fine)

But when I try to refer to it in a Kustomize file (shown above), I get an error:

Error: accumulating resources: accumulation err='accumulating resources from '../../../../../var/folders/2b/ryb_dw7j1gg183b46_ppt5sr0000gn/T/folder': evalsymlink failure on '/Users/var/folders/2b/ryb_dw7j1gg183b46_ppt5sr0000gn/T/folder' : lstat /Users/var: no such file or directory': must build at directory: not a valid directory: evalsymlink failure on '/Users/var/folders/2b/ryb_dw7j1gg183b46_ppt5sr0000gn/T/folder' : lstat /Users/var: no such file or directory

The problem is that, for some reason, now all the sudden, Kustomize is looking in /Users? /Users/var/folders/2b/ryb_dw7j1gg183b46_ppt5sr0000gn/T/folder does indeed not exist, but it's not the path I've given to Kustomize.

It probably has something to do with symlinking on Mac, but I'm confused as to why it does work when building the file directly, but not when it's referred to in another Kustomize file.

What did you expect to happen?

A successful build

How can we reproduce it (as minimally and precisely as possible)?

  1. Create a temp dir on MacOS, I did it in Go with os.TempDir()
  2. Add a Kustomize file in it
  3. Refer to it from somewhere else on the filesystem

Expected output

N/A

Actual output

An error

Kustomize version

v5.4.3

Operating system

MacOS

leonardj78 commented 2 months ago

This happens on linux as well.

We ran into the same issue. If you have nested kustomizations, it will break.

Previous structure that worked prior to this version.

kubernetes/qualityenv/kustomization.yaml kubernetes/qualityenv/build-test/kustomization.yaml

Running "kustomize localize qualityenv/build-test localized/qualityenv-build-test --scope ." breaks.

If you flatten the folder structure it will work.

basically we had to work around by changing our structure to

kubernetes/qualityenv/kustomization.yaml kubernetes/qualityenv-build-test/kustomization.yaml

and run kustomize localize qualityenv-build-test localized/qualityenv-build-test --scope .

stormqueen1990 commented 2 months ago

Hi there, @Stef16Robbe! Thanks for reporting this issue.

I was unable to reproduce it on MacOS, even with a latest head build. Would you be able to provide a minimal example that replicates the problem described?

/triage needs-information