fluxcd / flux2

Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit.
https://fluxcd.io
Apache License 2.0
6.33k stars 591 forks source link

flux fails to bootstrap a repo in a different Windows drive than the one in $env:TEMP #1153

Open pellegrino opened 3 years ago

pellegrino commented 3 years ago

Describe the bug

When trying to bootstrap a new flux repository on Windows, if the target directory is in a different drive than $env:TEMP, flux will fail to bootstrap it, with the error below:

github.com/pellegrino/test-flux2-windows on ☁️  (eu-central-1)
❯ pwd

Path
----
D:\src\github.com\pellegrino\test-flux2-windows

github.com/pellegrino/test-flux2-windows on ☁️  (eu-central-1)
❯ flux bootstrap github --owner=pellegrino --repository=my-repo --branch=main --path .\clusters\dok8s --personal
► connecting to github.com
✔ repository cloned
✚ generating manifests
✗ generating install manifests failed: Rel: can't make C:\Users\VITORP~1\AppData\Local\Temp\flux-system445357215 relative to D:\src\github.com\pellegrino\test-flux2-windows

My $env:TEMP lives inside the C:. I haven't tested changing it to a different drive to see if that has any impact.

❯ echo $env:TEMP
C:\Users\VITORP~1\AppData\Local\Temp

To Reproduce

Steps to reproduce the behavior:

  1. Create a new directory in a drive different than your $env:TEMP. I created mine on D:\
  2. Use flux bootstrap to initialize the repo. Flux should fail to install the manifests

Expected behavior

The new directory being bootstrap with the flux manifest files.

Additional context

flux version

❯ flux --version
flux version 0.10.0

flux check

❯ flux check --pre
► checking prerequisites
✔ kubectl 1.19.7 >=1.18.0-0
✔ Kubernetes 1.20.2 >=1.16.0-0
✔ prerequisites checks passed
simongottschlag commented 3 years ago

Hi!

I think the error comes from here: https://github.com/fluxcd/flux2/blob/main/pkg/manifestgen/manifest.go#L40-L43

Most likely related to securejoin: https://github.com/cyphar/filepath-securejoin/blob/master/join.go

Not sure how it should be handled though.

Ping @stefanprodan @phillebaba

dzmitry-lahoda commented 2 years ago

Me to here. Have to copy our repos to disk C.

domoran commented 2 years ago

I just got that error too. I realized that it happened, when I ran the flux bootstrap from a different drive than drive C ... After switching to drive C the execution worked!

I realized that the OP also used different drives, so hopefully this can provide a workaround until this is solved.

D:\Code\gitops>flux bootstrap github --components-extra=image-reflector-controller,image-automation-controller --hostname=some-repository --ssh-hostname=some-repository --owner=xyz--repository=gitops  --branch=master
► connecting to some-repository
► cloning branch "master" from Git repository "https://some-repository/xyz/gitops.git"
✔ cloned repository
► generating component manifests
✗ component manifest generation failed: Rel: can't make C:\Users\xyz\AppData\Local\Temp\flux-manifests-3183109114 relative to D:\Code\gitops

D:\Code\gitops>c:

C:\Users\xyz>flux bootstrap github --components-extra=image-reflector-controller,image-automation-controller --hostname=some-repository --ssh-hostname=some-repository --owner=xyz --repository=gitops  --branch=master
► connecting to some-repository
► cloning branch "master" from Git repository "https://some-repository/xyz/gitops.git"
✔ cloned repository
► generating component manifests
✔ generated component manifests
✔ committed sync manifests to "master" ("464255e37c49724b85c07bef23408d6c91654bd5")
► pushing component manifests to "https://some-repository/xyz/gitops.git"
► installing components in "flux-system" namespace
✔ installed components
✔ reconciled components
► determining if source secret "flux-system/flux-system" exists
► generating source secret
...
Saoirse-Derry commented 2 years ago

I can confirm moving to c resolves the issue

thesn10 commented 2 years ago

Please fix. Its been more than two months without any signs of an effort to fix this isssue.

majid-rafei commented 2 years ago

Yes, it works from drive C

kitforbes commented 2 years ago

Just wanted to add that I tried changing $env:TEMP to a directory on the other drive as @pellegrino hadn't tested that, but the same error occurs.

I'm running Flux with the Terraform provider, so it's inconvenient to move my repositories to a different drive, but I'll do it until a solution is implemented.

bravecobra commented 2 years ago

Just wanted to add that I tried changing $env:TEMP to a directory on the other drive as @pellegrino hadn't tested that, but the same error occurs.

I'm running Flux with the Terraform provider, so it's inconvenient to move my repositories to a different drive, but I'll do it until a solution is implemented.

As a workaround I run my terraform commands on WSL. It then uses the linux version of terraform but in most cases that works for me.

mloskot commented 1 year ago

I confirm the problem still exists in Flux 0.41.2

I'm simply learning Flux and trying the podinfo deployment as tutorial in Git Bash session:

$ flux install --namespace=flux-system --network-policy=false --components=source-controller,helm-controller
✚ generating manifests
✗ install failed: Rel: can't make C:\Users\mateuszl\AppData\Local\Temp\flux-system2569008128 relative to F:\tmp

In case other confused Flux newbies arrive here, switching to WSL session works around the problem easily, without moving files away from F: or re-installing Flux, just go inside /mnt/f/tmp and re-run the command above. Thanks @bravecobra

basit9958 commented 1 year ago

/assign

basit9958 commented 1 year ago

It seems that the root path provided to SecureJoinVFS is on a different drive than the one specified in $env:TEMP, which causes an issue when resolving the symbolic links. To resolve this issue, you may want to ensure that the root path provided to SecureJoinVFS is on the same drive as the one specified in $env:TEMP.

ngothiensinh commented 7 months ago

can't make C:\Users\... relative to D:\src\github.com\...

You don't really need to move the source code the the C:/ Just use CD to change the current folder where you execute the fux cli