diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-03-18 06:35:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-18 06:35:39 -0700 |
commit | ea54a1c2f51d3173649277939738ce9b1c392076 (patch) | |
tree | 8ef53c80e18dbc1b7ee7e513eef4a6c86855346c /libpod | |
parent | 310155b4ee8f61aed4ff7f7a8056441f3971b536 (diff) | |
parent | 232b46a3741267d8dd77a81196699d551c7a682e (diff) | |
download | podman-ea54a1c2f51d3173649277939738ce9b1c392076.tar.gz podman-ea54a1c2f51d3173649277939738ce9b1c392076.tar.bz2 podman-ea54a1c2f51d3173649277939738ce9b1c392076.zip |
Merge pull request #2670 from giuseppe/runtime-write-rootless-conf-before-reload
rootless: write the custom config file before reload
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/runtime.go | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index 9836b7aab..b3b75d791 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -505,24 +505,33 @@ func newRuntimeFromConfig(userConfigPath string, options ...RuntimeOption) (runt return nil, errors.Wrapf(err, "error configuring runtime") } } - if err := makeRuntime(runtime); err != nil { - return nil, err - } - - if !foundConfig && rootlessConfigPath != "" { - os.MkdirAll(filepath.Dir(rootlessConfigPath), 0755) - file, err := os.OpenFile(rootlessConfigPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) - if err != nil && !os.IsExist(err) { - return nil, errors.Wrapf(err, "cannot open file %s", rootlessConfigPath) + if rootlessConfigPath != "" { + // storage.conf + storageConfFile := util.StorageConfigFile() + if _, err := os.Stat(storageConfFile); os.IsNotExist(err) { + if err := util.WriteStorageConfigFile(&runtime.config.StorageConfig, storageConfFile); err != nil { + return nil, errors.Wrapf(err, "cannot write config file %s", storageConfFile) + } } - if err == nil { - defer file.Close() - enc := toml.NewEncoder(file) - if err := enc.Encode(runtime.config); err != nil { - os.Remove(rootlessConfigPath) + + if !foundConfig { + os.MkdirAll(filepath.Dir(rootlessConfigPath), 0755) + file, err := os.OpenFile(rootlessConfigPath, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) + if err != nil && !os.IsExist(err) { + return nil, errors.Wrapf(err, "cannot open file %s", rootlessConfigPath) + } + if err == nil { + defer file.Close() + enc := toml.NewEncoder(file) + if err := enc.Encode(runtime.config); err != nil { + os.Remove(rootlessConfigPath) + } } } } + if err := makeRuntime(runtime); err != nil { + return nil, err + } return runtime, nil } |