Skip to content

Commit

Permalink
Reset GraphDriverOptions, and storageOptions when called multiple times
Browse files Browse the repository at this point in the history
Currently in Podman if we reset the CONTAINERS_STORAGE_CONF path, we get
the graph driver options from the original config file as well as the
options from the override path. This PR resets the storageconf to the
initial state when called multiple times.

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Mar 31, 2021
1 parent 163e570 commit 1007bdd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) {
fmt.Printf("Failed to parse %s %v\n", configFile, err.Error())
return
}
storeOptions.GraphDriverName = ""
if config.Storage.Driver != "" {
storeOptions.GraphDriverName = config.Storage.Driver
}
Expand All @@ -288,15 +289,20 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) {
if storeOptions.GraphDriverName == "" {
logrus.Errorf("The storage 'driver' option must be set in %s, guarantee proper operation.", configFile)
}
storeOptions.RunRoot = ""
if config.Storage.RunRoot != "" {
storeOptions.RunRoot = config.Storage.RunRoot
}
storeOptions.GraphRoot = ""
if config.Storage.GraphRoot != "" {
storeOptions.GraphRoot = config.Storage.GraphRoot
}
storeOptions.RootlessStoragePath = ""
if config.Storage.RootlessStoragePath != "" {
storeOptions.RootlessStoragePath = config.Storage.RootlessStoragePath
}
// Reset GraphDriverOptions in case this function is called multiple times.
storeOptions.GraphDriverOptions = []string{}
for _, s := range config.Storage.Options.AdditionalImageStores {
storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, fmt.Sprintf("%s.imagestore=%s", config.Storage.Driver, s))
}
Expand Down Expand Up @@ -334,30 +340,34 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) {
storeOptions.GIDMap = mappings.GIDs()
}

storeOptions.UIDMap = nil
uidmap, err := idtools.ParseIDMap([]string{config.Storage.Options.RemapUIDs}, "remap-uids")
if err != nil {
fmt.Print(err)
} else {
storeOptions.UIDMap = append(storeOptions.UIDMap, uidmap...)
storeOptions.UIDMap = uidmap
}
storeOptions.GIDMap = nil
gidmap, err := idtools.ParseIDMap([]string{config.Storage.Options.RemapGIDs}, "remap-gids")
if err != nil {
fmt.Print(err)
} else {
storeOptions.GIDMap = append(storeOptions.GIDMap, gidmap...)
storeOptions.GIDMap = gidmap
}
storeOptions.RootAutoNsUser = config.Storage.Options.RootAutoUsernsUser
storeOptions.AutoNsMinSize = 0
if config.Storage.Options.AutoUsernsMinSize > 0 {
storeOptions.AutoNsMinSize = config.Storage.Options.AutoUsernsMinSize
}
storeOptions.AutoNsMaxSize = 0
if config.Storage.Options.AutoUsernsMaxSize > 0 {
storeOptions.AutoNsMaxSize = config.Storage.Options.AutoUsernsMaxSize
}

storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, cfg.GetGraphDriverOptions(storeOptions.GraphDriverName, config.Storage.Options)...)

if os.Getenv("STORAGE_OPTS") != "" {
storeOptions.GraphDriverOptions = append(storeOptions.GraphDriverOptions, strings.Split(os.Getenv("STORAGE_OPTS"), ",")...)
storeOptions.GraphDriverOptions = strings.Split(os.Getenv("STORAGE_OPTS"), ",")
}
if len(storeOptions.GraphDriverOptions) == 1 && storeOptions.GraphDriverOptions[0] == "" {
storeOptions.GraphDriverOptions = nil
Expand Down

0 comments on commit 1007bdd

Please sign in to comment.