From cf1b8c2ab37194d46315b4c91e3e02317287f8ff Mon Sep 17 00:00:00 2001 From: Aditya Rajan Date: Thu, 2 Dec 2021 17:07:02 +0530 Subject: [PATCH 1/2] options: fall back to default graph and run root for empty case While reloading from config files `graph` and `run` root could be set to empty. We should fall back to default if they are empty. See: https://github.com/containers/podman/issues/12467 Signed-off-by: Aditya Rajan --- types/options.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/options.go b/types/options.go index fe4274efdd..b006dbd625 100644 --- a/types/options.go +++ b/types/options.go @@ -53,6 +53,13 @@ func init() { } ReloadConfigurationFileIfNeeded(defaultConfigFile, &defaultStoreOptions) } + // reload could set values to empty for run and graph root if config does not contains anything + if defaultStoreOptions.RunRoot == "" { + defaultStoreOptions.RunRoot = "/run/containers/storage" + } + if defaultStoreOptions.GraphRoot == "" { + defaultStoreOptions.GraphRoot = "/var/lib/containers/storage" + } } // defaultStoreOptionsIsolated is an internal implementation detail of DefaultStoreOptions to allow testing. From 0bc7e4dd525f920eb6514f1bf98b6bffbba87636 Mon Sep 17 00:00:00 2001 From: Aditya Rajan Date: Thu, 2 Dec 2021 21:28:48 +0530 Subject: [PATCH 2/2] options: use global const for run and graph root Signed-off-by: Aditya Rajan --- types/options.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/types/options.go b/types/options.go index b006dbd625..e42b6f2437 100644 --- a/types/options.go +++ b/types/options.go @@ -27,6 +27,13 @@ type tomlConfig struct { } `toml:"storage"` } +const ( + // these are default path for run and graph root for rootful users + // for rootless path is constructed via getRootlessStorageOpts + defaultRunRoot string = "/run/containers/storage" + defaultGraphRoot string = "/var/lib/containers/storage" +) + // defaultConfigFile path to the system wide storage.conf file var ( defaultConfigFile = "/usr/share/containers/storage.conf" @@ -37,8 +44,8 @@ var ( ) func init() { - defaultStoreOptions.RunRoot = "/run/containers/storage" - defaultStoreOptions.GraphRoot = "/var/lib/containers/storage" + defaultStoreOptions.RunRoot = defaultRunRoot + defaultStoreOptions.GraphRoot = defaultGraphRoot defaultStoreOptions.GraphDriverName = "" if _, err := os.Stat(defaultOverrideConfigFile); err == nil { @@ -55,10 +62,10 @@ func init() { } // reload could set values to empty for run and graph root if config does not contains anything if defaultStoreOptions.RunRoot == "" { - defaultStoreOptions.RunRoot = "/run/containers/storage" + defaultStoreOptions.RunRoot = defaultRunRoot } if defaultStoreOptions.GraphRoot == "" { - defaultStoreOptions.GraphRoot = "/var/lib/containers/storage" + defaultStoreOptions.GraphRoot = defaultGraphRoot } }