From f139a7c83c7bc4c2303a1010180109bc70af9b8d78477c15ef8d4e4ecd004933 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Tue, 17 Jan 2023 09:41:34 +0000 Subject: [PATCH 1/2] Accepting request 1058234 from home:danishprakash:branches:devel:microos - Make the priority for picking the storage driver configurable (bsc#1197093) (backport of https://github.com/containers/storage/pull/1460) - add patch: 0002-Make-the-priority-for-picking-the-storage-driver-con.patch OBS-URL: https://build.opensuse.org/request/show/1058234 OBS-URL: https://build.opensuse.org/package/show/devel:microos/podman?expand=0&rev=12 --- ...y-for-picking-the-storage-driver-con.patch | 264 ++++++++++++++++++ podman.changes | 7 + podman.spec | 1 + 3 files changed, 272 insertions(+) create mode 100644 0002-Make-the-priority-for-picking-the-storage-driver-con.patch diff --git a/0002-Make-the-priority-for-picking-the-storage-driver-con.patch b/0002-Make-the-priority-for-picking-the-storage-driver-con.patch new file mode 100644 index 0000000..e2e3e79 --- /dev/null +++ b/0002-Make-the-priority-for-picking-the-storage-driver-con.patch @@ -0,0 +1,264 @@ +From 575166520c8f7e9c46b63bc2b47721512613614b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= +Date: Tue, 3 Jan 2023 16:34:25 +0100 +Subject: [PATCH 1/2] Make the priority for picking the storage driver + configurable +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This fixes https://github.com/containers/storage/issues/1457 + +Co-authored-by: Valentin Rothberg +Signed-off-by: Dan Čermák +--- + .../containers/storage/drivers/driver.go | 18 +++- + vendor/github.com/containers/storage/store.go | 89 ++++++++++--------- + .../containers/storage/types/options.go | 14 ++- + 3 files changed, 71 insertions(+), 50 deletions(-) + +diff --git a/vendor/github.com/containers/storage/drivers/driver.go b/vendor/github.com/containers/storage/drivers/driver.go +index 7d96ebe54..68d1956b8 100644 +--- a/vendor/github.com/containers/storage/drivers/driver.go ++++ b/vendor/github.com/containers/storage/drivers/driver.go +@@ -312,6 +312,7 @@ func getBuiltinDriver(name, home string, options Options) (Driver, error) { + type Options struct { + Root string + RunRoot string ++ DriverPriority []string + DriverOptions []string + UIDMaps []idtools.IDMap + GIDMaps []idtools.IDMap +@@ -327,9 +328,18 @@ func New(name string, config Options) (Driver, error) { + + // Guess for prior driver + driversMap := scanPriorDrivers(config.Root) +- for _, name := range priority { +- if name == "vfs" { +- // don't use vfs even if there is state present. ++ ++ // use the supplied priority list unless it is empty ++ prioList := config.DriverPriority ++ if len(prioList) == 0 { ++ prioList = priority ++ } ++ ++ for _, name := range prioList { ++ if name == "vfs" && len(config.DriverPriority) == 0 { ++ // don't use vfs even if there is state present and vfs ++ // has not been explicitly added to the override driver ++ // priority list + continue + } + if _, prior := driversMap[name]; prior { +@@ -362,7 +372,7 @@ func New(name string, config Options) (Driver, error) { + } + + // Check for priority drivers first +- for _, name := range priority { ++ for _, name := range prioList { + driver, err := getBuiltinDriver(name, config.Root, config) + if err != nil { + if isDriverNotSupported(err) { +diff --git a/vendor/github.com/containers/storage/store.go b/vendor/github.com/containers/storage/store.go +index fb1faaa13..7dc8df948 100644 +--- a/vendor/github.com/containers/storage/store.go ++++ b/vendor/github.com/containers/storage/store.go +@@ -606,29 +606,30 @@ type ContainerOptions struct { + } + + type store struct { +- lastLoaded time.Time +- runRoot string +- graphLock Locker +- usernsLock Locker +- graphRoot string +- graphDriverName string +- graphOptions []string +- pullOptions map[string]string +- uidMap []idtools.IDMap +- gidMap []idtools.IDMap +- autoUsernsUser string +- additionalUIDs *idSet // Set by getAvailableIDs() +- additionalGIDs *idSet // Set by getAvailableIDs() +- autoNsMinSize uint32 +- autoNsMaxSize uint32 +- graphDriver drivers.Driver +- layerStore LayerStore +- roLayerStores []ROLayerStore +- imageStore ImageStore +- roImageStores []ROImageStore +- containerStore ContainerStore +- digestLockRoot string +- disableVolatile bool ++ lastLoaded time.Time ++ runRoot string ++ graphLock Locker ++ usernsLock Locker ++ graphRoot string ++ graphDriverName string ++ graphOptions []string ++ graphDriverPriority []string ++ pullOptions map[string]string ++ uidMap []idtools.IDMap ++ gidMap []idtools.IDMap ++ autoUsernsUser string ++ additionalUIDs *idSet // Set by getAvailableIDs() ++ additionalGIDs *idSet // Set by getAvailableIDs() ++ autoNsMinSize uint32 ++ autoNsMaxSize uint32 ++ graphDriver drivers.Driver ++ layerStore LayerStore ++ roLayerStores []ROLayerStore ++ imageStore ImageStore ++ roImageStores []ROImageStore ++ containerStore ContainerStore ++ digestLockRoot string ++ disableVolatile bool + } + + // GetStore attempts to find an already-created Store object matching the +@@ -724,21 +725,22 @@ func GetStore(options types.StoreOptions) (Store, error) { + autoNsMaxSize = AutoUserNsMaxSize + } + s := &store{ +- runRoot: options.RunRoot, +- graphLock: graphLock, +- graphRoot: options.GraphRoot, +- graphDriverName: options.GraphDriverName, +- graphOptions: options.GraphDriverOptions, +- uidMap: copyIDMap(options.UIDMap), +- gidMap: copyIDMap(options.GIDMap), +- autoUsernsUser: options.RootAutoNsUser, +- autoNsMinSize: autoNsMinSize, +- autoNsMaxSize: autoNsMaxSize, +- additionalUIDs: nil, +- additionalGIDs: nil, +- usernsLock: usernsLock, +- disableVolatile: options.DisableVolatile, +- pullOptions: options.PullOptions, ++ runRoot: options.RunRoot, ++ graphLock: graphLock, ++ graphRoot: options.GraphRoot, ++ graphDriverName: options.GraphDriverName, ++ graphDriverPriority: options.GraphDriverPriority, ++ graphOptions: options.GraphDriverOptions, ++ uidMap: copyIDMap(options.UIDMap), ++ gidMap: copyIDMap(options.GIDMap), ++ autoUsernsUser: options.RootAutoNsUser, ++ autoNsMinSize: autoNsMinSize, ++ autoNsMaxSize: autoNsMaxSize, ++ additionalUIDs: nil, ++ additionalGIDs: nil, ++ usernsLock: usernsLock, ++ disableVolatile: options.DisableVolatile, ++ pullOptions: options.PullOptions, + } + if err := s.load(); err != nil { + return nil, err +@@ -868,11 +870,12 @@ func (s *store) getGraphDriver() (drivers.Driver, error) { + return s.graphDriver, nil + } + config := drivers.Options{ +- Root: s.graphRoot, +- RunRoot: s.runRoot, +- DriverOptions: s.graphOptions, +- UIDMaps: s.uidMap, +- GIDMaps: s.gidMap, ++ Root: s.graphRoot, ++ RunRoot: s.runRoot, ++ DriverOptions: s.graphOptions, ++ DriverPriority: s.graphDriverPriority, ++ UIDMaps: s.uidMap, ++ GIDMaps: s.gidMap, + } + driver, err := drivers.New(s.graphDriverName, config) + if err != nil { +diff --git a/vendor/github.com/containers/storage/types/options.go b/vendor/github.com/containers/storage/types/options.go +index 4c873b45f..4fbe512a9 100644 +--- a/vendor/github.com/containers/storage/types/options.go ++++ b/vendor/github.com/containers/storage/types/options.go +@@ -19,6 +19,7 @@ import ( + type TomlConfig struct { + Storage struct { + Driver string `toml:"driver,omitempty"` ++ DriverPriority []string `toml:"driver_priority,omitempty"` + RunRoot string `toml:"runroot,omitempty"` + GraphRoot string `toml:"graphroot,omitempty"` + RootlessStoragePath string `toml:"rootless_storage_path,omitempty"` +@@ -189,10 +190,16 @@ type StoreOptions struct { + // RootlessStoragePath is the storage path for rootless users + // default $HOME/.local/share/containers/storage + RootlessStoragePath string `toml:"rootless_storage_path"` +- // GraphDriverName is the underlying storage driver that we'll be +- // using. It only needs to be specified the first time a Store is +- // initialized for a given RunRoot and GraphRoot. ++ // If the driver is not specified, the best suited driver will be picked ++ // either from GraphDriverPriority, if specified, or from the platform ++ // dependent priority list (in that order). + GraphDriverName string `json:"driver,omitempty"` ++ // GraphDriverPriority is a list of storage drivers that will be tried ++ // to initialize the Store for a given RunRoot and GraphRoot unless a ++ // GraphDriverName is set. ++ // This list can be used to define a custom order in which the drivers ++ // will be tried. ++ GraphDriverPriority []string `json:"driver-priority,omitempty"` + // GraphDriverOptions are driver-specific options. + GraphDriverOptions []string `json:"driver-options,omitempty"` + // UIDMap and GIDMap are used for setting up a container's root filesystem +@@ -357,6 +364,7 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) erro + if storeOptions.GraphDriverName == "" { + logrus.Errorf("The storage 'driver' option must be set in %s to guarantee proper operation", configFile) + } ++ storeOptions.GraphDriverPriority = config.Storage.DriverPriority + if config.Storage.RunRoot != "" { + storeOptions.RunRoot = config.Storage.RunRoot + } +-- +2.39.0 + + +From de3c3805b23abf90ce1300cf78686411abc57644 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= +Date: Fri, 6 Jan 2023 08:22:57 +0100 +Subject: [PATCH 2/2] Only warn about 'driver' not being set if the priority + list is unset +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Currently we would display an error when the user does not specify a `driver` in +their config file. This has been present for historical reasons mostly to +prevent users from accidentally getting the vfs +driver (https://github.com/containers/storage/pull/1460#issuecomment-1370866271). Now +that most systems support the overlay driver natively, we can reduce this to a +warning and only warn about it if the driver_priority list is unset. If it is +provided, then clearly the user or the distribution wanted for c/storage to pick +a driver itself and the warning would be only confusing to users. + +Signed-off-by: Dan Čermák +--- + vendor/github.com/containers/storage/types/options.go | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/vendor/github.com/containers/storage/types/options.go b/vendor/github.com/containers/storage/types/options.go +index 4fbe512a9..e87f458cc 100644 +--- a/vendor/github.com/containers/storage/types/options.go ++++ b/vendor/github.com/containers/storage/types/options.go +@@ -361,10 +361,10 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) erro + logrus.Warnf("Switching default driver from overlay2 to the equivalent overlay driver") + storeOptions.GraphDriverName = overlayDriver + } +- if storeOptions.GraphDriverName == "" { +- logrus.Errorf("The storage 'driver' option must be set in %s to guarantee proper operation", configFile) +- } + storeOptions.GraphDriverPriority = config.Storage.DriverPriority ++ if storeOptions.GraphDriverName == "" && len(storeOptions.GraphDriverPriority) == 0 { ++ logrus.Warnf("The storage 'driver' option should be set in %s. A driver was picked automatically.", configFile) ++ } + if config.Storage.RunRoot != "" { + storeOptions.RunRoot = config.Storage.RunRoot + } +-- +2.39.0 + diff --git a/podman.changes b/podman.changes index 88e4ffd..00f7d09 100644 --- a/podman.changes +++ b/podman.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Jan 13 12:46:24 UTC 2023 - Danish Prakash + +- Make the priority for picking the storage driver configurable (bsc#1197093) + (backport of https://github.com/containers/storage/pull/1460) +- add patch: 0002-Make-the-priority-for-picking-the-storage-driver-con.patch + ------------------------------------------------------------------- Tue Nov 22 08:20:16 UTC 2022 - dcermak@suse.com diff --git a/podman.spec b/podman.spec index 9219b65..0d253c4 100644 --- a/podman.spec +++ b/podman.spec @@ -29,6 +29,7 @@ Source1: podman.conf Source2: README.SUSE.SLES # hotfix for https://github.com/containers/podman/issues/16765 Patch0: 0001-Revert-Default-missing-hostPort-to-containerPort-is-.patch +Patch1: 0002-Make-the-priority-for-picking-the-storage-driver-con.patch BuildRequires: bash-completion BuildRequires: cni BuildRequires: device-mapper-devel From 777b2b5cf856c4ab26faf070cfd53ed852267d71633002e946662a99051db2a5 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Tue, 17 Jan 2023 12:32:32 +0000 Subject: [PATCH 2/2] Accepting request 1058887 from home:danishprakash:branches:devel:microos - add patch: 0003-Only-override-the-graphdriver-to-vfs-if-the-priority.patch (backport of https://github.com/containers/storage/pull/1468) OBS-URL: https://build.opensuse.org/request/show/1058887 OBS-URL: https://build.opensuse.org/package/show/devel:microos/podman?expand=0&rev=13 --- ...e-graphdriver-to-vfs-if-the-priority.patch | 44 +++++++++++++++++++ podman.changes | 6 +++ podman.spec | 1 + 3 files changed, 51 insertions(+) create mode 100644 0003-Only-override-the-graphdriver-to-vfs-if-the-priority.patch diff --git a/0003-Only-override-the-graphdriver-to-vfs-if-the-priority.patch b/0003-Only-override-the-graphdriver-to-vfs-if-the-priority.patch new file mode 100644 index 0000000..efb01bb --- /dev/null +++ b/0003-Only-override-the-graphdriver-to-vfs-if-the-priority.patch @@ -0,0 +1,44 @@ +From 3f6a1954ff440959adcc44cc58372ed13ae2dbb3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= +Date: Fri, 13 Jan 2023 14:39:54 +0100 +Subject: [PATCH] Only override the graphdriver to vfs if the priority is unset +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This is an amend to https://github.com/containers/storage/pull/1460 + +That PR was not addressing the case when the system wide config had the +driver_priority option configured and the user had no config file of their +own. Then `getRootlessStorageOpts` would be called and it would override the +graph driver to "vfs". + +With this commit we only override the graph driver if driver priority is +empty. Otherwise we propagate the driver priority into the storage options, so +that the driver autodetection works as expected. + +Signed-off-by: Dan Čermák +--- + vendor/github.com/containers/storage/types/options.go | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/vendor/github.com/containers/storage/types/options.go b/vendor/github.com/containers/storage/types/options.go +index e87f458cc..eb7142ff2 100644 +--- a/vendor/github.com/containers/storage/types/options.go ++++ b/vendor/github.com/containers/storage/types/options.go +@@ -274,7 +274,11 @@ func getRootlessStorageOpts(rootlessUID int, systemOpts StoreOptions) (StoreOpti + } + } + if opts.GraphDriverName == "" { +- opts.GraphDriverName = "vfs" ++ if len(systemOpts.GraphDriverPriority) == 0 { ++ opts.GraphDriverName = "vfs" ++ } else { ++ opts.GraphDriverPriority = systemOpts.GraphDriverPriority ++ } + } + + if os.Getenv("STORAGE_OPTS") != "" { +-- +2.39.0 + diff --git a/podman.changes b/podman.changes index 00f7d09..0eace8a 100644 --- a/podman.changes +++ b/podman.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Jan 17 10:42:42 UTC 2023 - Danish Prakash + +- add patch: 0003-Only-override-the-graphdriver-to-vfs-if-the-priority.patch + (backport of https://github.com/containers/storage/pull/1468) + ------------------------------------------------------------------- Fri Jan 13 12:46:24 UTC 2023 - Danish Prakash diff --git a/podman.spec b/podman.spec index 0d253c4..7515262 100644 --- a/podman.spec +++ b/podman.spec @@ -30,6 +30,7 @@ Source2: README.SUSE.SLES # hotfix for https://github.com/containers/podman/issues/16765 Patch0: 0001-Revert-Default-missing-hostPort-to-containerPort-is-.patch Patch1: 0002-Make-the-priority-for-picking-the-storage-driver-con.patch +Patch2: 0003-Only-override-the-graphdriver-to-vfs-if-the-priority.patch BuildRequires: bash-completion BuildRequires: cni BuildRequires: device-mapper-devel