spiegel_podman/libpod
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
..
define fix container inspect output to not escape html chars 2026-04-23 20:12:14 +02:00
driver RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
events RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
layers Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
linkmode chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
lock RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
logs RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
namesgenerator libpod: include names-generator.go 2026-03-09 16:08:43 +01:00
plugin RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
shutdown enable gofumpt formatter 2025-11-11 12:32:46 +01:00
boltdb_state.go Re-add a minimal version of BoltDB for migrations 2026-05-05 15:42:04 -04:00
boltdb_state_internal.go Re-add a minimal version of BoltDB for migrations 2026-05-05 15:42:04 -04:00
common_test.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container.go libpod: limit splitting of cgroup fields 2026-04-30 09:52:08 -07:00
container_api.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_commit.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_config.go Merge pull request #28567 from Honny1/small-fix 2026-04-23 06:03:47 +02:00
container_copy_common.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_copy_freebsd.go Mount volumes before copying into a container 2024-11-27 08:09:50 -05:00
container_copy_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_exec.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
container_graph.go Add migration code for BoltDB to SQLite 2026-05-08 14:07:17 -04:00
container_graph_test.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_healthcheck_test.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:36 +01:00
container_inspect.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_inspect_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_inspect_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_internal.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_internal_common.go Merge pull request #28494 from agp8x/fix/keep-pod-hostname 2026-04-28 17:52:39 +02:00
container_internal_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_internal_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_internal_linux_test.go libpod: limit splitting of cgroup fields 2026-04-30 09:52:08 -07:00
container_internal_test.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:53 +01:00
container_linux.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
container_log.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_log_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_log_unsupported.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_path_resolution.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_path_resolution_test.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:36 +01:00
container_secrets_test.go run modernize -fix ./... 2026-03-12 17:22:01 +01:00
container_stat_common.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_stat_freebsd.go RUN-4538: Fix buildah vendoring 2026-04-21 14:27:58 -05:00
container_stat_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_top_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_top_linux.c libpod/container_top_linux.c: fix missing header 2024-06-27 10:50:17 +02:00
container_top_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
container_top_unsupported.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:53 +01:00
container_validate.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
diff.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
doc.go document that using libpod package directly is not supported 2022-03-23 19:05:29 +01:00
events.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
healthcheck.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
healthcheck_config.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
healthcheck_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
healthcheck_nosystemd_linux.go lint: reenable revive unused-parameter check 2025-10-01 10:42:08 -04:00
healthcheck_unsupported.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:53 +01:00
info.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
info_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
info_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
info_test.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
kube.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
mounts_linux.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
networking_common.go Merge pull request #28567 from Honny1/small-fix 2026-04-23 06:03:47 +02:00
networking_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
networking_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
networking_linux_test.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
networking_machine.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:36 +01:00
networking_pasta_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
networking_rootlessport.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
oci.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
oci_conmon.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:36 +01:00
oci_conmon_attach_common.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
oci_conmon_attach_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
oci_conmon_attach_linux.go add missing O_CLOEXEC to open calls 2026-04-02 15:06:37 +02:00
oci_conmon_common.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
oci_conmon_exec_common.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
oci_conmon_exec_freebsd.go lint: reenable revive unused-parameter check 2025-10-01 10:42:08 -04:00
oci_conmon_exec_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
oci_conmon_freebsd.go lint: reenable revive unused-parameter check 2025-10-01 10:42:08 -04:00
oci_conmon_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
oci_missing.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
oci_util.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
options.go Add migration code for BoltDB to SQLite 2026-05-08 14:07:17 -04:00
pod.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
pod_api.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
pod_internal.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
pod_internal_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
pod_internal_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
pod_status.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
pod_top_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
pod_top_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
reset.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
rlimit_int64.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
rlimit_uint64.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
runtime.go Add migration code for BoltDB to SQLite 2026-05-08 14:07:17 -04:00
runtime_cstorage.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
runtime_ctr.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
runtime_ctr_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
runtime_ctr_linux.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
runtime_freebsd.go lint: reenable revive unused-parameter check 2025-10-01 10:42:08 -04:00
runtime_img.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
runtime_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
runtime_migrate.go Add migration code for BoltDB to SQLite 2026-05-08 14:07:17 -04:00
runtime_migrate_freebsd.go libpod: fix a confusing error message from 'podman system reset' on FreeBSD 2025-02-11 15:13:29 +00:00
runtime_migrate_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
runtime_pod.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
runtime_pod_common.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
runtime_pod_freebsd.go lint: reenable revive unused-parameter check 2025-10-01 10:42:08 -04:00
runtime_pod_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
runtime_pre_go1.20.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
runtime_renumber.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
runtime_test.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:36 +01:00
runtime_volume.go Merge pull request #28413 from simonbrauner/issue-26786 2026-04-28 13:59:42 -04:00
runtime_volume_common.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
runtime_worker.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:36 +01:00
service.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
sqlite_state.go Add migration code for BoltDB to SQLite 2026-05-08 14:07:17 -04:00
sqlite_state_internal.go Add migration code for BoltDB to SQLite 2026-05-08 14:07:17 -04:00
state.go Move to deterministic network setup order 2026-04-17 10:00:32 -04:00
state_test.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
stats_common.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
stats_freebsd.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
stats_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
storage.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
util.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
util_freebsd.go lint: reenable revive unused-parameter check 2025-10-01 10:42:08 -04:00
util_linux.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
util_linux_test.go lint: reenable revive unused-parameter check 2025-10-01 10:42:08 -04:00
util_test.go Make most of libpod, and everything that relies on it, non-darwin 2026-02-27 22:18:36 +01:00
volume.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
volume_inspect.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
volume_internal.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
volume_internal_common.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00
volume_internal_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
volume_internal_linux.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
volume_test.go RUN-4539: Change podman module paths 2026-04-22 14:02:25 -05:00