mirror of https://github.com/containers/podman.git
Set default paths from DB if not explicitly overridden
If the DB contains default paths, and the user has not explicitly overridden them, use the paths in the DB over our own defaults. The DB validates these paths, so it would error and prevent operation if they did not match. As such, instead of erroring, we can use the DB's paths instead of our own. Signed-off-by: Matthew Heon <mheon@redhat.com>
This commit is contained in:
parent
aa7ce33b7a
commit
92ff83f5b9
|
@ -73,9 +73,10 @@ func (s *InMemoryState) Refresh() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetDBConfig is not implemented for the in-memory state
|
||||
// GetDBConfig is not implemented for in-memory state.
|
||||
// As we do not store a config, return an empty one.
|
||||
func (s *InMemoryState) GetDBConfig() (*DBConfig, error) {
|
||||
return nil, ErrNotImplemented
|
||||
return &DBConfig{}, nil
|
||||
}
|
||||
|
||||
// ValidateDBConfig is not implemented for the in-memory state.
|
||||
|
|
|
@ -484,7 +484,31 @@ func makeRuntime(runtime *Runtime) (err error) {
|
|||
return errors.Wrapf(ErrInvalidArg, "unrecognized state type passed")
|
||||
}
|
||||
|
||||
// Validate our config against the database
|
||||
// Grab config from the database so we can reset some defaults
|
||||
dbConfig, err := runtime.state.GetDBConfig()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error retrieving runtime configuration from database")
|
||||
}
|
||||
|
||||
// Reset defaults if they were not explicitly set
|
||||
if !runtime.configuredFrom.storageGraphDriverSet && dbConfig.GraphDriver != "" {
|
||||
runtime.config.StorageConfig.GraphDriverName = dbConfig.GraphDriver
|
||||
}
|
||||
if !runtime.configuredFrom.storageGraphRootSet && dbConfig.StorageRoot != "" {
|
||||
runtime.config.StorageConfig.GraphRoot = dbConfig.StorageRoot
|
||||
}
|
||||
if !runtime.configuredFrom.storageRunRootSet && dbConfig.StorageTmp != "" {
|
||||
runtime.config.StorageConfig.RunRoot = dbConfig.StorageTmp
|
||||
}
|
||||
if !runtime.configuredFrom.libpodStaticDirSet && dbConfig.LibpodRoot != "" {
|
||||
runtime.config.StaticDir = dbConfig.LibpodRoot
|
||||
}
|
||||
if !runtime.configuredFrom.libpodTmpDirSet && dbConfig.LibpodTmp != "" {
|
||||
runtime.config.TmpDir = dbConfig.LibpodTmp
|
||||
}
|
||||
|
||||
// Validate our config against the database, now that we've set our
|
||||
// final storage configuration
|
||||
if err := runtime.state.ValidateDBConfig(runtime); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue