diff options
author | Matthew Heon <mheon@redhat.com> | 2018-11-29 11:36:16 -0500 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2018-12-02 13:38:36 -0500 |
commit | b0f79ff4df58c12fdfaff5c4a7c6e029cb566459 (patch) | |
tree | e68862845156d312c132ac3e9969f5dfd8d42827 /libpod | |
parent | 6e167029478e29d24ff75d259123e7f7e093b6ff (diff) | |
download | podman-b0f79ff4df58c12fdfaff5c4a7c6e029cb566459.tar.gz podman-b0f79ff4df58c12fdfaff5c4a7c6e029cb566459.tar.bz2 podman-b0f79ff4df58c12fdfaff5c4a7c6e029cb566459.zip |
Move DB configuration up in runtime setup
When we configure a runtime, we now will need to hit the DB early
on, so we can verify the paths we're going to use for c/storage are correct.
Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/runtime.go | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go index 9feae03fc..8615e5e12 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -426,6 +426,33 @@ func makeRuntime(runtime *Runtime) (err error) { runtime.config.ConmonPath) } + // Set up the state + switch runtime.config.StateType { + case InMemoryStateStore: + state, err := NewInMemoryState() + if err != nil { + return err + } + runtime.state = state + case SQLiteStateStore: + return errors.Wrapf(ErrInvalidArg, "SQLite state is currently disabled") + case BoltDBStateStore: + dbPath := filepath.Join(runtime.config.StaticDir, "bolt_state.db") + + state, err := NewBoltState(dbPath, runtime.lockDir, runtime) + if err != nil { + return err + } + runtime.state = state + default: + return errors.Wrapf(ErrInvalidArg, "unrecognized state type passed") + } + + if err := runtime.state.SetNamespace(runtime.config.Namespace); err != nil { + return errors.Wrapf(err, "error setting libpod namespace in state") + } + logrus.Debugf("Set libpod namespace to %q", runtime.config.Namespace) + // Set up containers/storage var store storage.Store if rootless.SkipStorageSetup() { @@ -540,33 +567,6 @@ func makeRuntime(runtime *Runtime) (err error) { } runtime.firewallBackend = fwBackend - // Set up the state - switch runtime.config.StateType { - case InMemoryStateStore: - state, err := NewInMemoryState() - if err != nil { - return err - } - runtime.state = state - case SQLiteStateStore: - return errors.Wrapf(ErrInvalidArg, "SQLite state is currently disabled") - case BoltDBStateStore: - dbPath := filepath.Join(runtime.config.StaticDir, "bolt_state.db") - - state, err := NewBoltState(dbPath, runtime.lockDir, runtime) - if err != nil { - return err - } - runtime.state = state - default: - return errors.Wrapf(ErrInvalidArg, "unrecognized state type passed") - } - - if err := runtime.state.SetNamespace(runtime.config.Namespace); err != nil { - return errors.Wrapf(err, "error setting libpod namespace in state") - } - logrus.Debugf("Set libpod namespace to %q", runtime.config.Namespace) - // We now need to see if the system has restarted // We check for the presence of a file in our tmp directory to verify this // This check must be locked to prevent races |