Skip to content
Permalink
Browse files
feat(buildah): support autodetection of native mode for overlayfs
  • Loading branch information
distorhead committed Dec 10, 2021
1 parent c87f7c3 commit 7858360a502087cecafebf026523d4a4033a3da6
Showing with 21 additions and 7 deletions.
  1. +1 −1 pkg/buildah/common.go
  2. +3 −2 pkg/buildah/docker_with_fuse.go
  3. +17 −4 pkg/buildah/native_linux.go
@@ -175,7 +175,7 @@ func ResolveMode(mode Mode) Mode {
}
}

func GetOverlayOptions() ([]string, error) {
func GetFuseOverlayfsOptions() ([]string, error) {
fuseOverlayBinPath, err := exec.LookPath("fuse-overlayfs")
if err != nil {
return nil, fmt.Errorf("\"fuse-overlayfs\" binary not found in PATH: %s", err)
@@ -276,11 +276,12 @@ func runStorageContainer(ctx context.Context, name, image string) error {
func newBuildahCliStoreOptions(driver StorageDriver) (*StoreOptions, error) {
var graphDriverOptions []string
if driver == StorageDriverOverlay {
overlayOpts, err := GetOverlayOptions()
fuseOpts, err := GetFuseOverlayfsOptions()
if err != nil {
return nil, fmt.Errorf("unable to get overlay options: %s", err)
}
graphDriverOptions = append(graphDriverOptions, overlayOpts...)
graphDriverOptions = append(graphDriverOptions, fuseOpts...)
graphDriverOptions = append(graphDriverOptions, fmt.Sprintf("%s.ignore_chown_errors=true", StorageDriverOverlay))
}

return &StoreOptions{
@@ -13,6 +13,8 @@ import (
"strings"
"time"

"github.com/containers/storage/drivers/overlay"

"github.com/containers/buildah"
"github.com/containers/buildah/define"
"github.com/containers/buildah/imagebuildah"
@@ -360,12 +362,23 @@ func NewNativeStoreOptions(rootlessUID int, driver StorageDriver) (*thirdparty.S
}

var graphDriverOptions []string
if driver == StorageDriverOverlay {
overlayOpts, err := GetOverlayOptions()
switch driver {
case StorageDriverOverlay:
supportsNative, err := overlay.SupportsNativeOverlay(graphRoot, runRoot)
if err != nil {
return nil, fmt.Errorf("unable to get overlay options: %s", err)
return nil, fmt.Errorf("unable to check native overlayfs support: %s", err)
}
graphDriverOptions = append(graphDriverOptions, overlayOpts...)

if !supportsNative {
fuseOpts, err := GetFuseOverlayfsOptions()
if err != nil {
return nil, fmt.Errorf("unable to get fuse overlayfs options: %s", err)
}

graphDriverOptions = append(graphDriverOptions, fuseOpts...)
}

graphDriverOptions = append(graphDriverOptions, fmt.Sprintf("%s.ignore_chown_errors=true", StorageDriverOverlay))
}

return &thirdparty.StoreOptions{

0 comments on commit 7858360

Please sign in to comment.