willdurand / containers

📦 This is a repository with some code I wrote to learn more about containers.
https://williamdurand.fr/2022/06/21/deep-dive-into-containers/
Apache License 2.0
9 stars 0 forks source link

Investigate `.wh..wh..opq` files #66

Open willdurand opened 2 years ago

willdurand commented 2 years ago

I am not sure what that kind of file is but it breaks yaman... It looks like some marker file for volumes? I am not sure so let's investigate.

Below is a patch to "workaround" the problems I had but that's certainly not the right approach:

diff --git a/internal/yaman/container/container.go b/internal/yaman/container/container.go
index 54911bf..5543a3f 100644
--- a/internal/yaman/container/container.go
+++ b/internal/yaman/container/container.go
@@ -88,6 +88,24 @@ func (c *Container) MakeBundle() error {
        return fmt.Errorf("failed to mount overlay: %w", err)
    }

+   // HACK: kinda fix an issue with `.wh..wh..opq`
+   for volume := range imageConfig.Config.Volumes {
+       volumeDir := filepath.Join(c.RootFS(), volume)
+       if stat, err := os.Stat(volumeDir); err == nil {
+           st, ok := stat.Sys().(*syscall.Stat_t)
+           if !ok {
+               continue
+           }
+
+           logrus.Debugf("recreating %s", volumeDir)
+           if err := os.RemoveAll(volumeDir); err == nil {
+               if err := os.MkdirAll(volumeDir, 0o755); err == nil {
+                   os.Chown(volumeDir, int(st.Uid), int(st.Gid))
+               }
+           }
+       }
+   }
+
    // Convert image config into a runtime config.
    // See: https://github.com/opencontainers/image-spec/blob/main/conversion.md
    cwd := "/"
willdurand commented 2 years ago

Looks like this patch above isnt strictly needed.. In #103, I was able to run containers with a volume and this file and that was ok.

We should clearly recreate (or at least clear) directories with that kind of files, though.