Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options: keep using prior drivers if found #1618

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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