Skip to content

Commit

Permalink
Fix podman info to return configured additional image stores
Browse files Browse the repository at this point in the history
The command `podman info` returned only one imagestore in
`store.graphOptions.<driver>.imagestore` even if multiple
image stores were configured.

This change replaces the field `<driver>.imagestore` with
the field `<driver>.additionalImageStores`, that instead
of a string is an array of strings and that includes all
the configured additional image stores.

Signed-off-by: Mario Loriedo <[email protected]>
  • Loading branch information
l0rd committed Dec 2, 2024
1 parent b3c0268 commit 0b6899b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libpod/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ func (r *Runtime) storeInfo() (*define.StoreInfo, error) {
graphOptions := map[string]interface{}{}
for _, o := range r.store.GraphOptions() {
split := strings.SplitN(o, "=", 2)
if strings.HasSuffix(split[0], "mount_program") {
switch {
case strings.HasSuffix(split[0], "mount_program"):
ver, err := version.Program(split[1])
if err != nil {
logrus.Warnf("Failed to retrieve program version for %s: %v", split[1], err)
Expand All @@ -260,7 +261,14 @@ func (r *Runtime) storeInfo() (*define.StoreInfo, error) {
program["Version"] = ver
program["Package"] = version.Package(split[1])
graphOptions[split[0]] = program
} else {
case strings.HasSuffix(split[0], "imagestore"):
key := strings.ReplaceAll(split[0], "imagestore", "additionalImageStores")
if graphOptions[key] == nil {
graphOptions[key] = []string{split[1]}
} else {
graphOptions[key] = append(graphOptions[key].([]string), split[1])
}
default:
graphOptions[split[0]] = split[1]
}
}
Expand Down
29 changes: 29 additions & 0 deletions test/system/005-info.bats
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,35 @@ host.slirp4netns.executable | $expr_path
is "$output" ".*graphOptions: {}" "output includes graphOptions: {}"
}

@test "podman info - additional image stores" {
if [[ -z "$CI_DESIRED_STORAGE" ]]; then
# When running in Cirrus, CI_DESIRED_STORAGE *must* be defined
# in .cirrus.yml so we can double-check that all CI VMs are
# using overlay or vfs as desired.
if [[ -n "$CIRRUS_CI" ]]; then
die "CIRRUS_CI is set, but CI_DESIRED_STORAGE is not! See #20161"
fi

# Not running under Cirrus (e.g., gating tests, or dev laptop).
# Totally OK to skip this test.
skip "CI_DESIRED_STORAGE is unset--OK, because we're not in Cirrus"
fi
is "$(podman_storage_driver)" "$CI_DESIRED_STORAGE" "podman storage driver is not CI_DESIRED_STORAGE (from .cirrus.yml)"
skip_if_remote "--storage-opt flag is not supported for remote"
# Only overlay storage driver supports additional image stores
if [[ "$CI_DESIRED_STORAGE" = "overlay" ]]; then
store1=$PODMAN_TMPDIR/store1
store2=$PODMAN_TMPDIR/store2
mkdir -p $store1 $store2
run_podman info --storage-opt='overlay.imagestore='$store1 \
--storage-opt='overlay.imagestore='$store2 \
--format '{{index .Store.GraphOptions "overlay.additionalImageStores"}}'
is "$output" "["$store1" "$store2"]" "output includes additional image stores"
else
skip "additional image stores are only supported with overlay storage driver"
fi
}

@test "podman info netavark " {
# Confirm netavark in use when explicitly required by execution environment.
if [[ "$NETWORK_BACKEND" == "netavark" ]]; then
Expand Down

0 comments on commit 0b6899b

Please sign in to comment.