Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix additional image stores in podman info #24731

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

l0rd
Copy link
Member

@l0rd l0rd commented Dec 2, 2024

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 is an array of strings that includes all the configured additional image stores.

Fix containers/storage#2094

Does this PR introduce a user-facing change?

Fix `podman info` when there are multiple additional image stores

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 2, 2024
Comment on lines 186 to 198
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)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unnecessary, the test does not have to depend on any CI setup so it shouldn't as we should be able to run that locally.

Just call $(podman_storage_driver) to know the current driver

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will do that

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That isn't true, vfs supports extra imagestores as well so the condition is not needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this means the old imagestore field is no longer included while the certainly was buggy it might be that users depend on that field somehow so we should not remove it and keep for backwards compat at least until 6.0 IMO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can keep that key as well, with the same logic if you think it can break someone.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR updated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need both. imagestore refers to a path where images will be stored. This feature is mostly used by CRI-O to split containers and images on two different file systems. It is not the same as additionalimagestores.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@giuseppe I see that there are 2 different configs in storage.conf:

[storage]
imagestore = "/first/path"

[storage.options]
additionalimagestores = [ "second/path" ] 

But podman info returns only the additionalimagestores path:

...
store:
  ...
  graphOptions:
    overlay.imagestore: "second/path"
    overlay.additionalImageStores: ["second/path"]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRI-O shouldn't be affected by what podman info returns (this PR change), right?

@l0rd l0rd force-pushed the additionalimagestores branch from 0b6899b to 0aa347a Compare December 2, 2024 15:11
store1=$PODMAN_TMPDIR/store1
store2=$PODMAN_TMPDIR/store2
mkdir -p $store1 $store2
run_podman info --storage-opt=$(podman_storage_driver)'.imagestore='$store1 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you cache $(podman_storage_driver) in a var? It seems the function calls podman info each time and info is a rather slow command.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

mkdir -p $store1 $store2
run_podman info --storage-opt=$(podman_storage_driver)'.imagestore='$store1 \
--storage-opt=$(podman_storage_driver)'.imagestore='$store2 \
--format '{{index .Store.GraphOptions "'$(podman_storage_driver)'.additionalImageStores"}}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{index .Store.GraphOptions "'$(podman_storage_driver)'.additionalImageStores"}}\n{{index .Store.GraphOptions "'$(podman_storage_driver)'.imagestore"}}

Can you use this format then check

assert "${lines[0]}" == "["$store1" "$store2"]" "output includes additional image stores"
assert "${lines[1]}" == "$store2" "old imagestore output"

In general assert should be preferred over is as is has some rather dangerous pitfalls, i.e. your current test can end up broken as [] is valid regex so is may assume it should perfom a regex match not an exact match.
With assert you must specify == or =~ so there is no ambiguity

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

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.

Fix containers/storage#2094

Signed-off-by: Mario Loriedo <[email protected]>
@l0rd l0rd force-pushed the additionalimagestores branch from 0aa347a to 0d3a653 Compare December 2, 2024 15:37
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Copy link
Contributor

openshift-ci bot commented Dec 2, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: l0rd, Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@baude
Copy link
Member

baude commented Dec 3, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 3, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 45ac4e2 into containers:main Dec 3, 2024
79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GraphOptions mixes image store with additional image stores (which are not returned)
4 participants