Skip to content

Conversation

mheon
Copy link
Member

@mheon mheon commented Sep 24, 2025

This is accomplished by a new flag, --rewrite-config, which instructs the database to replace cached paths. Before this, the only real way to change paths like tmpdir, runroot, graphroot, etc was to do a podman system reset then change the config files before running another Podman command. Now, changing the config files and running any Podman command with
--rewrite-config should be sufficient to pick up the new paths.

Please note that this can only be done with no containers, pods, and volumes present. Otherwise, we risk the breakages that caching paths was supposed to prevent in the first place.

This is SQLite only, given the deprecation and impending removal of BoltDB.

Does this PR introduce a user-facing change?

Added a new global Podman option, `--rewrite-config`, to rewrite cached configuration values in the database. This allows configuration changes to important paths to be made without a `podman system reset`.

Copy link
Contributor

openshift-ci bot commented Sep 24, 2025

[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 Sep 24, 2025
@mheon mheon force-pushed the allow_db_config_rewrite branch 2 times, most recently from 5d82351 to 8245598 Compare September 24, 2025 20:28
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@baude
Copy link
Member

baude commented Sep 24, 2025

first pass lgtm

rm -rf "$RUNROOT_B"
rm -rf "$GRAPHROOT"
}

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 do tests for the error conditions as defined in this if?

@mheon mheon force-pushed the allow_db_config_rewrite branch 8 times, most recently from 9549389 to 0cc16bf Compare September 30, 2025 03:04
@mheon
Copy link
Member Author

mheon commented Oct 1, 2025

This is ready

Comment on lines +127 to +133
#### **--rewrite-config**
When true, cached configuration values in the database will be rewritten.
Normally, changes to certain configuration values - graphDriver, graphRoot, and runRoot in storage.conf, as well as static_dir, tmp_dir, and volume_path in containers.conf - will be ignored until a `podman system reset`, as old values cached in the database will be used.
This is done to ensure that configuration changes do not break existing pods, containers, and volumes present in the database.
This option rewrites the cached values in the database, replacing them with the current configuration.
This can only be done if no containers, pods, and volumes are present, to prevent the breakage described earlier.
If any containers, pods, or volumes are present, an error will be returned.
Copy link
Member

Choose a reason for hiding this comment

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

What is the point of making this a global flag that applies to every command? That seems design wise not ideal, it means user could just start using that with any command and I fear it leads to users setting this on all commands then just making the scripts and such ugly?
Would something like this not be better done only for system migrate?

Also if it is gated on no containers, volumes, pods (which I agree is an important security detail) then how much would this flag help compared to running system reset? I guess the only benifit is you get to keep the images?

Copy link
Member Author

Choose a reason for hiding this comment

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

It keeps networks, machines, images - so there's probably some value in it.

I wouldn't be opposed to adding this to system migrate but I do kind of hate how loaded with unintended side-effects that command has become.

Copy link
Member

Choose a reason for hiding this comment

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

yeah system migrate may not be the perfect fit either but I find the global option worse?

Thinking about this is there a strong reason to require manual user invention at all? If we just fix it silently when there are no containers, pods, volumes then I guess the users are most happy. Because like that we still require that a user must somehow know about this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think doing it unconditionally is reasonable - the DB query to check if it's safe to rewrite should be very efficient (and can be made more efficient, I think, no need to get an actual count, just check if number of rows is non-zero).

Comment on lines 336 to 338
GRAPHROOT=$(mktemp -d)
RUNROOT_A=$(mktemp -d)
RUNROOT_B=$(mktemp -d)
Copy link
Member

Choose a reason for hiding this comment

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

This must use paths below $PODMAN_TMPDIR, and don't use rm -rf at the end since that is done already in teardown(). The way it is written now these paths are always leaked on test errors.


# First, verify original runRoot is used with first config
CONTAINERS_STORAGE_CONF=$STORAGE_CONF1 run_podman info
echo "$output" | grep -q "runRoot: $RUNROOT_A"
Copy link
Member

Choose a reason for hiding this comment

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

That is simply not the way how we write tests and check for output in the bats suite.

Please always use assert and if you want the runroot just call podman info --format "{{.Store.RunRoot}}" instead of the awkward grep, same in all the other places

This is accomplished by a new flag, `--rewrite-config`, which
instructs the database to replace cached paths. Before this, the
only real way to change paths like tmpdir, runroot, graphroot,
etc was to do a `podman system reset` then change the config
files before running another Podman command. Now, changing the
config files and running any Podman command with
`--rewrite-config` should be sufficient to pick up the new paths.

Please note that this can only be done with no containers, pods,
and volumes present. Otherwise, we risk the breakages that
caching paths was supposed to prevent in the first place.

This is SQLite only, given the deprecation and impending removal
of BoltDB.

Signed-off-by: Matt Heon <[email protected]>
@mheon mheon force-pushed the allow_db_config_rewrite branch from 0cc16bf to ffac7db Compare October 1, 2025 17:26
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 1, 2025
@openshift-merge-robot
Copy link
Collaborator

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants