summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpod/in_memory_state.go5
-rw-r--r--libpod/runtime.go26
2 files changed, 28 insertions, 3 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go
index 8cd2f47b9..77eba0cc6 100644
--- a/libpod/in_memory_state.go
+++ b/libpod/in_memory_state.go
@@ -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.
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 1e05810fb..e01fa781b 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -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
}