mirror of
https://github.com/containers/podman.git
synced 2025-12-01 18:49:18 +08:00
Remove BoltDB state support
This also includes a number of significant changes to the SQLite state made possible by removal of the legacy DB. 1. Enable database unit tests for SQLite state, with numerous tweaks to get tests passing. Most notable changes are to container removal - where we previously didn't return an error if there was no container to remove - and RemovePodContainers, which I don't think ever worked properly from my reading of the failures. 2. Removal of AddContainerToPod/RemoveContainerToPod. On SQLite, these functions are identical to AddContainer/RemoveContainer and there is no reason to retain duplicates. 3. Removal of SafeRewriteContainerConfig - it's identical to RewriteContainerConfig in SQLite, no reason to have duplicate entrypoints. As an exciting side-note, this removes Podman's requirement that containers and pods cannot share a name, which was a BoltDB restriction only. Signed-off-by: Matt Heon <matthew.heon@pm.me>
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
@@ -295,31 +294,11 @@ func getDBState(runtime *Runtime) (State, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// get default boltdb path
|
||||
baseDir := runtime.config.Engine.StaticDir
|
||||
if runtime.storageConfig.TransientStore {
|
||||
baseDir = runtime.config.Engine.TmpDir
|
||||
}
|
||||
boltDBPath := filepath.Join(baseDir, "bolt_state.db")
|
||||
|
||||
switch backend {
|
||||
case config.DBBackendDefault:
|
||||
// for backwards compatibility check if boltdb exists, if it does not we use sqlite
|
||||
if err := fileutils.Exists(boltDBPath); err != nil {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
// need to set DBBackend string so podman info will show the backend name correctly
|
||||
runtime.config.Engine.DBBackend = config.DBBackendSQLite.String()
|
||||
return NewSqliteState(runtime)
|
||||
}
|
||||
// Return error here some other problem with the boltdb file, rather than silently
|
||||
// switch to sqlite which would be hard to debug for the user return the error back
|
||||
// as this likely a real bug.
|
||||
return nil, err
|
||||
}
|
||||
runtime.config.Engine.DBBackend = config.DBBackendBoltDB.String()
|
||||
fallthrough
|
||||
case config.DBBackendBoltDB:
|
||||
return NewBoltState(boltDBPath, runtime)
|
||||
return nil, fmt.Errorf("the BoltDB database backend was removed in Podman 6.0")
|
||||
case config.DBBackendDefault:
|
||||
fallthrough
|
||||
case config.DBBackendSQLite:
|
||||
return NewSqliteState(runtime)
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user