mirror of
https://github.com/containers/podman.git
synced 2025-06-26 21:07:02 +08:00
Deprecate BoltDB, preventing creation of new databases.
This is one of the breaking changes in Podman 5.0: removing the ability to create new instances of the old Bolt database. This does not remove support for the database entirely, as existing Bolt databases will still be usable, but all new installs will use SQLite after this point - if Bolt is forced by config, we'll just error. We don't have plans to outright remove the Bolt code. If that were to happen, it'd be Podman 6.0 at least, and a significant enough change it'd warrant a lot of discussion and planning. We do intend to start winding down support of BoltDB, though, and new features may be added only to SQLite from here on. I have added an escape hatch via an undocumented environment variable that allows us to continue testing BoltDB in CI (and, if necessary, locally) but I don't want this to be used for any purpose except continued testing of the old DB to ensure we don't break it. Signed-off-by: Matt Heon <mheon@redhat.com>
This commit is contained in:
@ -6,7 +6,9 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -78,6 +80,19 @@ func NewBoltState(path string, runtime *Runtime) (State, error) {
|
||||
|
||||
logrus.Debugf("Initializing boltdb state at %s", path)
|
||||
|
||||
// BoltDB is deprecated and, as of Podman 5.0, we no longer allow the
|
||||
// creation of new Bolt states.
|
||||
// If the DB does not already exist, error out.
|
||||
// To continue testing in CI, allow creation iff an undocumented env
|
||||
// var is set.
|
||||
if os.Getenv("CI_DESIRED_DATABASE") != "boltdb" {
|
||||
if _, err := os.Stat(path); err != nil && errors.Is(err, fs.ErrNotExist) {
|
||||
return nil, fmt.Errorf("the BoltDB backend has been deprecated, no new BoltDB databases can be created: %w", define.ErrInvalidArg)
|
||||
}
|
||||
} else {
|
||||
logrus.Debugf("Allowing deprecated database backend due to CI_DESIRED_DATABASE.")
|
||||
}
|
||||
|
||||
db, err := bolt.Open(path, 0600, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("opening database %s: %w", path, err)
|
||||
|
@ -46,6 +46,10 @@ func getEmptyBoltState() (_ State, _ string, _ lock.Manager, retErr error) {
|
||||
}
|
||||
}()
|
||||
|
||||
if err := os.Setenv("CI_DESIRED_DATABASE", "boltdb"); err != nil {
|
||||
return nil, "", nil, err
|
||||
}
|
||||
|
||||
dbPath := filepath.Join(tmpDir, "db.sql")
|
||||
|
||||
lockManager, err := lock.NewInMemoryManager(16)
|
||||
|
Reference in New Issue
Block a user