Skip to content

Commit

Permalink
Merge pull request #1618 from flouthoc/default-vfs-old-users
Browse files Browse the repository at this point in the history
options: keep using prior drivers if found
  • Loading branch information
rhatdan authored May 26, 2023
2 parents cfa32d0 + 9ef15e4 commit 55ee2d1
Show file tree
Hide file tree
Showing 8 changed files with 27 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
21 changes: 17 additions & 4 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"time"

"github.com/BurntSushi/toml"
drivers "github.com/containers/storage/drivers"
_ "github.com/containers/storage/drivers/register"
cfg "github.com/containers/storage/pkg/config"
"github.com/containers/storage/pkg/idtools"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -310,10 +312,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 55ee2d1

Please sign in to comment.