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

Retain folder structure when copying files from ~/.minikube/files #2768

Closed
vinceho opened this issue Apr 26, 2018 · 17 comments
Closed

Retain folder structure when copying files from ~/.minikube/files #2768

vinceho opened this issue Apr 26, 2018 · 17 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@vinceho
Copy link

vinceho commented Apr 26, 2018

Environment:

  • Minikube version: v0.26.1
  • OS: Ubuntu 16.04
  • VM Driver: virtualbox
  • ISO version: v0.26.0

What happened:
When Minikube copies files onto the VM from ~/.minikube/files, the folder structure is not retained.

What you expected to happen:
On the host:

~/.minikube/files$ find . | sort
.
./abc
./abc/1.txt
./def
./def/2.txt
./def/ghi
./def/ghi/3.txt

However, when the VM is provisioned, all the files are put onto the first directory with content.

$ minikube ssh find /abc
/abc
/abc/3.txt
/abc/2.txt
/abc/1.txt

I expect the copied files to match the structure on my host.

How to reproduce it:

  1. Create a nested folder structure in ~/.minikube/files with some files.

    cd ~/.minikube/files
    mkdir -p {abc,def/ghi}
    touch abc/1.txt
    touch def/2.txt
    touch def/ghi/3.txt
    
  2. Start Minikube with minikube start --kubernetes-version v1.10.0 --bootstrapper=kubeadm.

  3. After completion, check the VM for the files with minikube ssh find /abc.

@vinceho vinceho changed the title ~/.minikube/files does not retain folder structure on the VM Copied files from ~/.minikube/files do not retain folder structure on the VM Apr 26, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 25, 2018
@sslavic
Copy link

sslavic commented Jul 30, 2018

This issue is even worse on Windows:

  • directories on VM get flattened compared to the source, as if Windows path separator \ just gets ignored/removed for directories
  • additionally destination is also not consistent with when minikube is run on Mac - instead of root /, files end up in /home/docker subdirectory.

E.g. C:\Users\foo\.minikube\files\foo\bar\baz.txt would end up in /home/docker/foobar/baz.txt

BTW copying of ~/.minikube/files to VM was added via #1914 / #1917

@mmhelm
Copy link

mmhelm commented Aug 14, 2018

The function parameter vmpath gets overwritten in the filepath.Walk function.

func addMinikubeDirToAssets(basedir, vmpath string, assets *[]CopyableFile) error {
    err := filepath.Walk(basedir, func(hostpath string, info os.FileInfo, err error) error {
        ...
        if !isDir {
            if vmpath == "" {
                ...
                vmpath = filepath.Join("/", rPath)
            }
            ...
            f, err := NewFileAsset(hostpath, vmpath, filepath.Base(hostpath), permString)
            ...
            *assets = append(*assets, f)
        }
        ...
    })
    ...
}

Thus after one iteration if vmpath == "" evaluates always to false, vmpath is never updated again and all FileAsset get the same target path. Fixed it in #3075 but I didn't focus on the issue on Windows @sslavic described above.

@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 13, 2018
@smiron
Copy link

smiron commented Sep 19, 2018

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Sep 19, 2018
@smiron
Copy link

smiron commented Sep 19, 2018

Any idea how to solve this on windows?

@tstromberg tstromberg added the kind/bug Categorizes issue or PR as related to a bug. label Sep 19, 2018
@tstromberg tstromberg changed the title Copied files from ~/.minikube/files do not retain folder structure on the VM Retain folder structure when copying files from ~/.minikube/files Sep 20, 2018
@tstromberg tstromberg added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Sep 20, 2018
@darkedges
Copy link

Does not work via git-bash on windows either.

My file structure
$MINIKUBE_HOME\.minikube\files\etc\ssl\certs\xxx.pem get squashed to /home/docker/etcsslcerts/xxx.pem

I am expecting to find the file in /etc/ssl/certs/xxx.pem

@mmhelm
Copy link

mmhelm commented Oct 9, 2018

@darkedges Could you please check if it works with pull request #3075?

@darkedges
Copy link

Will have a look. Having some issues building via docker on windows.

@darkedges
Copy link

@mmhelm It does not appear to work, directories are still squashed into the home directory.

@darkedges
Copy link

This seems to resolve it for me, #3258 will try and work out the CLA problem.

In essenc convert the path to unix format via

rPath = filepath.ToSlash(rPath)
vmpath = path.Join("/", rPath)

@gclawes
Copy link

gclawes commented Dec 3, 2018

I'm seeing a very similar issue on 0.30.0:

~ $ find ~/.minikube/files
/Users/gralaw/.minikube/files
/Users/gralaw/.minikube/files/etc
/Users/gralaw/.minikube/files/etc/ssl
/Users/gralaw/.minikube/files/etc/ssl/certs
/Users/gralaw/.minikube/files/etc/ssl/certs/ca-certificates.crt
/Users/gralaw/.minikube/files/etc/profile.d
/Users/gralaw/.minikube/files/etc/profile.d/proxy.sh
$ ls -lah /etc/profile.d
total 316K
drwxr-xr-x  2 root root    0 Dec  3 17:00 .
drwxr-xr-x 30 root root    0 Dec  3 17:00 ..
-rwxr-xr-x  1 root root 305K Dec  3 17:00 ca-certificates.crt
-rw-r--r--  1 root root  513 Dec  3 17:00 proxy.sh
-rw-r--r--  1 root root   10 Oct  5 20:05 umask.sh

@tstromberg
Copy link
Contributor

tstromberg commented Jan 24, 2019

Can someone confirm if this bug still exists in v0.33.1? There have been some recent changes to file handling that I'm curious about. If so, help wanted!

@tstromberg tstromberg added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. priority/backlog Higher priority than priority/awaiting-more-evidence. triage/needs-information Indicates an issue needs more information in order to work on it. labels Jan 24, 2019
@feniix
Copy link

feniix commented Mar 31, 2019

@tstromberg I can confirm that still exists in 0.33.1

@darkedges
Copy link

Works with 1.0.0 for me

C:\Users\NIrving\.minikube\files>minikube version
minikube version: v1.0.0

C:\Users\NIrving\.minikube\files>dir /s /b
C:\Users\NIrving\.minikube\files\etc
C:\Users\NIrving\.minikube\files\etc\profile.d
C:\Users\NIrving\.minikube\files\etc\ssl
C:\Users\NIrving\.minikube\files\etc\profile.d\test.txt
C:\Users\NIrving\.minikube\files\etc\ssl\test.txt

C:\Users\NIrving\.minikube\files>minikube ssh
                         _             _
            _         _ ( )           ( )
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __
/' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$ ls -la
total 0
drwxr-xr-x 3 docker docker 0 Mar 31 21:00 .
drwxr-xr-x 3 root   root   0 Mar 26 03:03 ..
drwx------ 2 docker docker 0 Mar 31 21:00 .ssh
$ ls -l /etc/profile.d
total 4
-rw-r--r-- 1 root root  0 Mar 31 21:01 test.txt
-rw-r--r-- 1 root root 10 Mar 26 02:15 umask.sh
$ ls -l /etc/ssl/test.txt
-rw-r--r-- 1 root root 0 Mar 31 21:01 /etc/ssl/test.txt

@darkedges
Copy link

darkedges commented Mar 31, 2019

But fails with v0.33.1

C:\Users\NIrving\Downloads>minikube-windows-amd64.exe version
minikube version: v0.33.1
C:\Users\NIrving\Downloads>minikube-windows-amd64.exe ssh
                         _             _
            _         _ ( )           ( )
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __
/' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$ pwd
/home/docker
$ ls
etcprofile.d

@rufreakde
Copy link

rufreakde commented Aug 21, 2020

I just wanted to copy my ca.cer file into minikubes directories on startup and it seems to work fine using OSX

minikube version: v1.12.3

my ca.cer file ->
etc/docker/certs.d/registry:port/ca.crt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests