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

[BUG] WARN Failed to check if the directory is empty: open data: no such file or directory #1977

Open
mcarbonneaux opened this issue Dec 18, 2024 · 0 comments · May be fixed by #1978
Open
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@mcarbonneaux
Copy link

mcarbonneaux commented Dec 18, 2024

Expected Behavior

no warning !
and normaly the massage must be ERR and not WARN!

Actual Behavior

when start convertion : WARN Failed to check if the directory is empty: open data: no such file or directory
the directory is not empty, it's containt only one sub directory.

Steps To Reproduce

  myservice:
    image: myimage/myimage
    restart: always
    ports:
      - 5333/tcp
    volumes:
      - /data/mydir:/opt/mydir
WARN Failed to check if the directory is empty: open data: no such file or directory
WARN Skip file in path /data/mydir

the /data/mydir is directory, and contain only one subdir... and /data is directory... and the sub directory containe multiple file...

Kompose Version

v1.33.0 and higher
it's work fine in v1.32.0

Docker-Compose file

myservice:
    image: myimage/myimage
    restart: always
    ports:
      - 5333/tcp
    volumes:
      - /data/mydir:/opt/mydir

Anything else?

i think the problem is in the function checkIsEmptyDir.
they try to recurse the filePath... they found in first a directory data...
but when call recursively checkIsEmptyDir the use relative name data, not the absolute name /data/mydir/data...
they break on first os.ReadDir... but is normal because they try to check data in place of /data/mydir/data.

// checkIsEmptyDir checks if filepath is empty
func checkIsEmptyDir(filePath string) (bool, error) {
files, err := os.ReadDir(filePath)
if err != nil {
return false, err
}
if len(files) == 0 {
return true, err
}
for _, file := range files {
if !file.IsDir() {
return false, nil
}
_, err := checkIsEmptyDir(file.Name())
if err != nil {
return false, err
}
}
return true, nil
}

@mcarbonneaux mcarbonneaux added the kind/bug Categorizes issue or PR as related to a bug. label Dec 18, 2024
@mcarbonneaux mcarbonneaux linked a pull request Dec 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant