spiegel_podman/pkg
Matt Heon d420fbfde3 Add migration code for BoltDB to SQLite
This is gated behind a new option in `podman system migrate`,
`--migrate-db`, or by a system restart being performed.

BoltDB support was removed in Podman 6, so we are certain that,
when we start Podman, a SQLite state is in use. However, if we
also detect a valid BoltDB state, we will attempt a migration.

Migration is performed by retrieving all volumes, pods, and
containers (in that order, to ensure there are no dependency
conflicts) from the Bolt database, when adding them to the SQLite
database. If there is a conflict - IE, a container exists in both
SQLite and Bolt - we skip migration for that object. The old DB
is then renamed so we do not try to migrate it again.

Our ability to test complex migration scenarios is limited, but
this should handle simple migrations easily.

This is a heavily adapted version of #27660 rebuilt to work with
Podman 6.0. Substantial changes were required to throw errors
when a BoltDB database is detected and no migration is being
performed. Firstly, for automatic on-reboot migrations, we need
to have a deferred error returned by getDBState (very early in
runtime initialization) that is only acted on much later (once we
know for certain a state refresh is/is not being performed).
The `system migrate --migrate-db` command was much more
problematic. Conceptually, it's not terrible - add a flag to the
runtime to suppress errors, set that flag only when calling the
`system migrate` command with `--migrate-db` - but it unveiled a
serious problem with how we do runtime init (special flags to the
runtime were being ignored because the image runtime set the
Libpod runtime first and had none of the proper handling) which
took a genuinely annoying amount of time to identify and fix.

This cannot be tested automatically, as the ability to create Bolt
databases has been entirely removed with Podman 6.

This also includes 9b810aed3a from
the v5.8 branch by Luap99, which I have had to squash into this
commit to satisfy the build-each-commit check. It was just a
simplification of the SQLite path check.

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2026-05-08 14:07:17 -04:00
..
annotations RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
api API: Add Health field to compat ListContainers and restrict to v1.52+ 2026-04-23 08:39:43 +00:00
auth api/compat: switch to moby/moby 2026-03-09 11:09:23 +01:00
autoupdate RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
bindings Fix lint issue with replace reflect.Ptr with reflect.Pointer 2026-05-04 13:48:36 +02:00
channel bump golangci-lint to v1.50.1 2022-12-15 13:39:56 +01:00
checkpoint RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
copy RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
criu lint: reenable revive unused-parameter check 2025-10-01 10:42:08 -04:00
ctime update golangci/golangci-lint to v1.63.4 2025-01-07 15:48:53 +01:00
domain Add migration code for BoltDB to SQLite 2026-05-08 14:07:17 -04:00
emulation pkg/emulation: remove slice copying 2026-02-11 11:41:10 -08:00
env run modernize -fix ./... 2025-09-10 16:17:04 +02:00
errorhandling pkg/errorhandling: remove deadcode 2025-06-26 19:37:14 +02:00
farm RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
fileserver RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
inspect RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
k8s.io RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
logiface run modernize -fix ./... 2025-09-10 16:17:04 +02:00
lookup Cease using deprecated runc userlookup 2024-02-02 11:02:43 -05:00
machine Merge pull request #28621 from l0rd/import-certs-darwin-linux 2026-05-05 13:10:57 +02:00
namespaces Remove slirp4netns setup functions (preserve RLK) 2026-04-13 09:04:41 -04:00
parallel RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
pidhandle add missing O_CLOEXEC to open calls 2026-04-02 15:06:37 +02:00
ps RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
rctl use strings.SplitSeq where possible 2025-09-10 16:17:04 +02:00
rootless RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
seccomp pkg: switch to golang native error wrapping 2022-07-08 08:54:47 +02:00
selinux Fix SELinux functions names to not be repetitive 2020-04-23 15:57:34 -04:00
signal enable gofumpt formatter 2025-11-11 12:32:46 +01:00
specgen specgen: memoize isMqueueSupported with sync.OnceValue 2026-05-05 14:41:26 +02:00
specgenutil RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
specgenutilexternal enable gofumpt formatter 2025-11-11 12:32:46 +01:00
syncmap Add syncmap package and use it for graph stop/remove 2025-02-17 14:32:34 -05:00
systemd RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
terminal Fix Lint on Windows and enable the job 2024-02-20 08:06:18 -05:00
trust trust: switch policy.json lookup to configfile 2026-04-20 15:11:22 +02:00
util RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00