From 6dd9abf9ec48f000efedde5b0cd2f89023efdd70 Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Thu, 20 Jun 2024 09:38:16 +0200 Subject: [PATCH] sqlite_state: Fix RewriteVolumeConfig The VolumeConfig table does not have an ID column, thus use the Name column to update it. Fixes #23052 Signed-off-by: Marius Hoch --- libpod/sqlite_state.go | 2 +- test/system/760-system-renumber.bats | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/system/760-system-renumber.bats diff --git a/libpod/sqlite_state.go b/libpod/sqlite_state.go index b54e33f49c..bee2210648 100644 --- a/libpod/sqlite_state.go +++ b/libpod/sqlite_state.go @@ -1310,7 +1310,7 @@ func (s *SQLiteState) RewriteVolumeConfig(volume *Volume, newCfg *VolumeConfig) } }() - results, err := tx.Exec("UPDATE VolumeConfig SET Name=?, JSON=? WHERE ID=?;", newCfg.Name, json, volume.Name()) + results, err := tx.Exec("UPDATE VolumeConfig SET Name=?, JSON=? WHERE Name=?;", newCfg.Name, json, volume.Name()) if err != nil { return fmt.Errorf("updating volume config table with new configuration for volume %s: %w", volume.Name(), err) } diff --git a/test/system/760-system-renumber.bats b/test/system/760-system-renumber.bats new file mode 100644 index 0000000000..d6763d065b --- /dev/null +++ b/test/system/760-system-renumber.bats @@ -0,0 +1,23 @@ +#!/usr/bin/env bats -*- bats -*- +# +# tests for podman system renumber +# + +load helpers + +function setup() { + basic_setup + + skip_if_remote "podman system renumber is not available remote" +} + +@test "podman system renumber - Basic test with a volume" { + run_podman volume create test + assert "$output" == "test" "podman volume create output" + run_podman system renumber + assert "$output" == "" "podman system renumber output" + run_podman volume rm test + assert "$output" == "test" "podman volume rm output" +} + +# vim: filetype=sh