Merge pull request #2131 from mheon/restore_storage_defaults

Use defaults if paths are not specified in storage.conf
This commit is contained in:
OpenShift Merge Robot
2019-01-10 11:58:13 -08:00
committed by GitHub

View File

@ -316,8 +316,20 @@ func GetDefaultStoreOptions() (storage.StoreOptions, string, error) {
storageConf := StorageConfigFile()
if _, err := os.Stat(storageConf); err == nil {
defaultRootlessRunRoot := storageOpts.RunRoot
defaultRootlessGraphRoot := storageOpts.GraphRoot
storageOpts = storage.StoreOptions{}
storage.ReloadConfigurationFile(storageConf, &storageOpts)
// If the file did not specify a graphroot or runroot,
// set sane defaults so we don't try and use root-owned
// directories
if storageOpts.RunRoot == "" {
storageOpts.RunRoot = defaultRootlessRunRoot
}
if storageOpts.GraphRoot == "" {
storageOpts.GraphRoot = defaultRootlessGraphRoot
}
} else if os.IsNotExist(err) {
os.MkdirAll(filepath.Dir(storageConf), 0755)
file, err := os.OpenFile(storageConf, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666)