Skip to content

Commit

Permalink
options: keep using prior drivers if found
Browse files Browse the repository at this point in the history
There is no need for `vfs` to be the default storage driver since kernel
>= 5.13 supports `overlay` natively however there is use-case for users
who don't had any configs and they started using `vfs` in a default
manner following check is a hack to keep `buildah` and `podman` working
for such users.

See: #1571 for prior
discussions.

Signed-off-by: Aditya R <arajan@redhat.com>
  • Loading branch information
flouthoc committed May 25, 2023
1 parent 60e72ea commit 783d62c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 14 deletions.
8 changes: 4 additions & 4 deletions drivers/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,12 @@ func New(name string, config Options) (Driver, error) {
}

// Guess for prior driver
driversMap := scanPriorDrivers(config.Root)
driversMap := ScanPriorDrivers(config.Root)

// use the supplied priority list unless it is empty
prioList := config.DriverPriority
if len(prioList) == 0 {
prioList = priority
prioList = Priority
}

for _, name := range prioList {
Expand Down Expand Up @@ -419,12 +419,12 @@ func isDriverNotSupported(err error) bool {
}

// scanPriorDrivers returns an un-ordered scan of directories of prior storage drivers
func scanPriorDrivers(root string) map[string]bool {
func ScanPriorDrivers(root string) map[string]bool {
driversMap := make(map[string]bool)

for driver := range drivers {
p := filepath.Join(root, driver)
if _, err := os.Stat(p); err == nil && driver != "vfs" {
if _, err := os.Stat(p); err == nil {
driversMap[driver] = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/driver_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package graphdriver

var (
// Slice of drivers that should be used in order
priority = []string{
Priority = []string{
"vfs",
}
)
Expand Down
2 changes: 1 addition & 1 deletion drivers/driver_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (

var (
// Slice of drivers that should be used in an order
priority = []string{
Priority = []string{
"zfs",
"vfs",
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/driver_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const (

var (
// Slice of drivers that should be used in an order
priority = []string{
Priority = []string{
"overlay",
// We don't support devicemapper without configuration
// "devicemapper",
Expand Down
2 changes: 1 addition & 1 deletion drivers/driver_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (

var (
// Slice of drivers that should be used in an order
priority = []string{
Priority = []string{
"zfs",
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/driver_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package graphdriver

var (
// Slice of drivers that should be used in an order
priority = []string{
Priority = []string{
"unsupported",
}
)
Expand Down
2 changes: 1 addition & 1 deletion drivers/driver_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package graphdriver

var (
// Slice of drivers that should be used in order
priority = []string{
Priority = []string{
"windowsfilter",
}
)
Expand Down
20 changes: 16 additions & 4 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/BurntSushi/toml"
drivers "github.com/containers/storage/drivers"
cfg "github.com/containers/storage/pkg/config"
"github.com/containers/storage/pkg/idtools"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -310,10 +311,21 @@ func getRootlessStorageOpts(rootlessUID int, systemOpts StoreOptions) (StoreOpti
}
if opts.GraphDriverName == "" {
if len(systemOpts.GraphDriverPriority) == 0 {
if canUseRootlessOverlay(opts.GraphRoot, opts.RunRoot) {
opts.GraphDriverName = overlayDriver
} else {
opts.GraphDriverName = "vfs"
driversMap := drivers.ScanPriorDrivers(opts.GraphRoot)

for _, name := range drivers.Priority {
if _, prior := driversMap[name]; prior {
opts.GraphDriverName = name
break
}
}

if opts.GraphDriverName == "" {
if canUseRootlessOverlay(opts.GraphRoot, opts.RunRoot) {
opts.GraphDriverName = overlayDriver
} else {
opts.GraphDriverName = "vfs"
}
}
} else {
opts.GraphDriverPriority = systemOpts.GraphDriverPriority
Expand Down

0 comments on commit 783d62c

Please sign in to comment.