Skip to content

Commit

Permalink
feat: wcow: add support for bind and cache mounts
Browse files Browse the repository at this point in the history
Currently, mounts are not supported for WCOW builds,
see #5678. This commit introduces support for
bind and cache mounts. The remaining two require
a little more work and consultation with the platform
teams for enlightment.

WIP Checklist:

- [x] Support for bind mounts
- [x] Support for cache mounts
- [x] add frontend/dockerfile integration tests
- [ ] add client integration tests
- [ ] add documentatio
- [ ] add note and plan on the missing feature(s)
	i.e. secret mounts (that need tmpfs)
- [ ] spec out / second attempt for SSH mount

Fixes #5603
Addresses part of #5678

Signed-off-by: Anthony Nandaa <[email protected]>
  • Loading branch information
profnandaa committed Feb 10, 2025
1 parent 3f4bcd3 commit 261ee88
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 39 deletions.
8 changes: 6 additions & 2 deletions executor/oci/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ func GenerateSpec(ctx context.Context, meta executor.Meta, mounts []executor.Mou
return nil, nil, err
}
s.Mounts = append(s.Mounts, specs.Mount{
Destination: m.Dest,
Type: mount.Type,
Destination: getAbsPath(m.Dest), // for Windows only
Type: getMountType(mount.Type),
Source: mount.Source,
Options: mount.Options,
})
Expand Down Expand Up @@ -243,6 +243,10 @@ type submounts struct {

func (s *submounts) subMount(m mount.Mount, subPath string) (mount.Mount, error) {
if path.Join("/", subPath) == "/" {
// for Windows, the mounting by HCS doesn't go through
// WCIFS, hence we have to give the direct path of the
// mount, which is in the /Files subdirectory.
m.Source = getCompleteSourcePath(m.Source)
return m, nil
}
if s.m == nil {
Expand Down
18 changes: 18 additions & 0 deletions executor/oci/spec_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//go:build !windows

package oci

// no effect for non-Windows
func getMountType(mType string) string {
return mType
}

// no effect for non-Windows
func getAbsPath(p string) string {
return p
}

// no effect for non-Windows
func getCompleteSourcePath(p string) string {
return p
}
19 changes: 19 additions & 0 deletions executor/oci/spec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,22 @@ func sub(m mount.Mount, subPath string) (mount.Mount, func() error, error) {
m.Source = src
return m, func() error { return nil }, nil
}

func getMountType(_ string) string {
// HCS shim doesn't expect a named type
// for the mount.
return ""
}

// Returns an absolute path, starting with the
// default drive letter (C:). HCS Shim expects an absolute path.
func getAbsPath(p string) string {
return filepath.Join("C:\\", p)
}

// For Windows, the mounting by HCS doesn't go through
// WCIFS, hence we have to give the direct path of the
// mount, which is in the /Files subdirectory.
func getCompleteSourcePath(p string) string {
return filepath.Join(p, "Files")
}
Loading

0 comments on commit 261ee88

Please sign in to comment.