Skip to content

Commit

Permalink
ReloadConfigurationFile should Reset storage options
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.

Also if user sets STORAGE_OPTS="" then we should use it to override all
other storage options.

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Apr 12, 2021
1 parent 5dc7256 commit c12c9e2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) {
fmt.Printf("Failed to parse %s %v\n", configFile, err.Error())
return
}

// Clear storeOptions of previos settings
*storeOptions = StoreOptions{}
if config.Storage.Driver != "" {
storeOptions.GraphDriverName = config.Storage.Driver
}
Expand Down Expand Up @@ -341,13 +344,13 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) {
if err != nil {
fmt.Print(err)
} else {
storeOptions.UIDMap = append(storeOptions.UIDMap, uidmap...)
storeOptions.UIDMap = uidmap
}
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
if config.Storage.Options.AutoUsernsMinSize > 0 {
Expand All @@ -359,8 +362,8 @@ func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) {

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"), ",")...)
if opts, ok := os.LookupEnv("STORAGE_OPTS"); ok {
storeOptions.GraphDriverOptions = strings.Split(opts, ",")
}
if len(storeOptions.GraphDriverOptions) == 1 && storeOptions.GraphDriverOptions[0] == "" {
storeOptions.GraphDriverOptions = nil
Expand Down

0 comments on commit c12c9e2

Please sign in to comment.