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

In SQLite state, use defaults for empty-string checks #24775

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mheon
Copy link
Member

@mheon mheon commented Dec 5, 2024

As part of our database init, we perform a check of the current values for a few fields (graph driver, graph root, static dir, and a few more) to validate that Libpod is being started with a sane & sensible config, and the user's containers can actually be expected to work. Basically, we take the current runtime config and compare against values cached in the database from the first time Podman was run.

We've had some issues with this logic before this year around symlink resolution, but this is a new edge case. Somehow, the database is being loaded with the empty string for some fields (at least graph driver) which is causing comparisons to fail because we will never compare against "" for those fields - we insert the default value instead, assuming we have one.

Having a value of "" in the database largely invalidates the check so arguably we could just drop it, but what BoltDB did - and what SQLite does after this patch - is to use the default value for comparison instead of "". This should still catch some edge cases, and shouldn't be too harmful.

What this does not do is identify or solve the reason that we are seeing the empty string in the database at all. From my read on the logic, it must mean that the graph driver is explicitly set to "" in the c/storage config at the time Podman is first run and I'm not precisely sure how that happens.

Fixes #24738

Does this PR introduce a user-facing change?

Fixed a bug where Podman would fail to start due to a database configuration mismatch when certain fields were configured to the empty string.

Copy link
Contributor

openshift-ci bot commented Dec 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mheon

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 5, 2024
@mheon mheon added the No New Tests Allow PR to proceed without adding regression tests label Dec 5, 2024
@mheon
Copy link
Member Author

mheon commented Dec 5, 2024

Adding no new tests as we don't do database config tests like this in CI

@Luap99
Copy link
Member

Luap99 commented Dec 5, 2024

The way to trigger this is create an empty storage.conf without driver then run podman to init db (you must reset the storage before of course)

$ podman ps
WARN[0000] The storage 'driver' option should be set in /home/pholzing/.config/containers/storage.conf. A driver was picked automatically. 
WARN[0000] The storage 'driver' option should be set in /home/pholzing/.config/containers/storage.conf. A driver was picked automatically. 
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES

# Follow the advice and add the driver, i.e. overlay
$ vi ~/.config/containers/storage.conf
$ cat ~/.config/containers/storage.conf
[storage]
driver="overlay"
$ podman ps
Error: database graph driver "" does not match our graph driver "overlay": database configuration mismatch

I think we can must test this somehow in CI.

I really must say they for every bug I dislike the validation logic more and more

@baude
Copy link
Member

baude commented Dec 5, 2024

could we just use the podman cli and the --storage-driver string? I think if you did an e2e test you could skip the step to prepopulate the image cache and then add the storage driver option as a one-off ?

@Luap99
Copy link
Member

Luap99 commented Dec 5, 2024

--storage-driver "" is ignored AFAIk so it must come from the config file I think. But that should not be much more difficult as we can use the CONTAINERS_STORAGE_CONF env to set it for a single test

@mheon mheon force-pushed the fix_24738 branch 2 times, most recently from 7df556c to 1e04b52 Compare December 10, 2024 15:46
@@ -291,4 +291,52 @@ var _ = Describe("Podman Info", func() {
Expect(info).ToNot(ExitCleanly())
podmanTest.StartRemoteService() // Start service again so teardown runs clean
})

It("podman startup: ensure database checks for graph driver accommodate empty string", func() {
Copy link
Member

Choose a reason for hiding this comment

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

Actually this will never work because all the e2e test pass all option via cli such as --storage-driver so it not matter what we set in the config.

I think this might have to be in test/system and you pass your own --root/-runroot/--tmpdir and just leave the driver to the storage .conf

As part of our database init, we perform a check of the current
values for a few fields (graph driver, graph root, static dir,
and a few more) to validate that Libpod is being started with a
sane & sensible config, and the user's containers can actually be
expected to work. Basically, we take the current runtime config
and compare against values cached in the database from the first
time Podman was run.

We've had some issues with this logic before this year around
symlink resolution, but this is a new edge case. Somehow, the
database is being loaded with the empty string for some fields
(at least graph driver) which is causing comparisons to fail
because we will never compare against "" for those fields - we
insert the default value instead, assuming we have one.

Having a value of "" in the database largely invalidates the
check so arguably we could just drop it, but what BoltDB did -
and what SQLite does after this patch - is to use the default
value for comparison instead of "". This should still catch some
edge cases, and shouldn't be too harmful.

What this does not do is identify or solve the reason that we are
seeing the empty string in the database at all. From my read on
the logic, it must mean that the graph driver is explicitly set
to "" in the c/storage config at the time Podman is first run and
I'm not precisely sure how that happens.

Fixes containers#24738

Signed-off-by: Matt Heon <[email protected]>
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. No New Tests Allow PR to proceed without adding regression tests release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: database graph driver "" does not match our graph driver "overlay": database configuration mismatch
3 participants