-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add ability to rewrite cached paths in the database #27157
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
Open
mheon
wants to merge
1
commit into
containers:main
Choose a base branch
from
mheon:allow_db_config_rewrite
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,4 +328,69 @@ EOF | |
CONTAINERS_STORAGE_CONF=$PODMAN_TMPDIR/storage.conf run_podman $safe_opts info | ||
} | ||
|
||
@test "podman info --rewrite-config respects new runRoot" { | ||
skip_if_remote "Test uses nonstandard paths for c/storage directories" | ||
skip_if_boltdb "Config rewrite only implemented for SQLite" | ||
|
||
# Create temporary storage directories | ||
GRAPHROOT=$PODMAN_TMPDIR/graphroot | ||
RUNROOT_A=$PODMAN_TMPDIR/runroota | ||
RUNROOT_B=$PODMAN_TMPDIR/runrootb | ||
|
||
STORAGE_CONF1=$PODMAN_TMPDIR/storage1.conf | ||
STORAGE_CONF2=$PODMAN_TMPDIR/storage2.conf | ||
|
||
cat >$STORAGE_CONF1 <<EOF | ||
[storage] | ||
driver="$(podman_storage_driver)" | ||
graphroot = "$GRAPHROOT" | ||
runroot = "$RUNROOT_A" | ||
[storage.options] | ||
EOF | ||
|
||
cat >$STORAGE_CONF2 <<EOF | ||
[storage] | ||
driver="$(podman_storage_driver)" | ||
graphroot = "$GRAPHROOT" | ||
runroot = "$RUNROOT_B" | ||
[storage.options] | ||
EOF | ||
|
||
# First, verify original runRoot is used with first config | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF1 run_podman info | ||
assert "$output" =~ "runRoot: $RUNROOT_A" "runRoot not properly set on first Podman call" | ||
|
||
# Second config should be ignored; still original runRoot | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF2 run_podman info | ||
assert "$output" =~ "runRoot: $RUNROOT_A" "runRoot overwritten by subsequent Podman call" | ||
|
||
# Rewrite with a container should fail | ||
randomctrname=c_$(safename) | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF1 run_podman create --name $randomctrname $IMAGE sh | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF2 run_podman 125 --rewrite-config info | ||
assert "$output" = "Error: refusing to rewrite database cached configuration as containers, pods, or volumes are present: internal libpod error" | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF1 run_podman rm $randomctrname | ||
|
||
# Rewrite with a pod should fail | ||
randompodname=p_$(safename) | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF1 run_podman pod create $randompodname | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF2 run_podman 125 --rewrite-config info | ||
assert "$output" = "Error: refusing to rewrite database cached configuration as containers, pods, or volumes are present: internal libpod error" | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF1 run_podman pod rm $randompodname | ||
|
||
# Rewrite with a volume should fail | ||
randomvolname=v_$(safename) | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF1 run_podman volume create $randomvolname | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF2 run_podman 125 --rewrite-config info | ||
assert "$output" = "Error: refusing to rewrite database cached configuration as containers, pods, or volumes are present: internal libpod error" | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF1 run_podman volume rm $randomvolname | ||
|
||
# With rewrite-config flag, new runRoot should be used | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF2 run_podman --rewrite-config info | ||
assert "$output" =~ "runRoot: $RUNROOT_B" "runRoot not overwritten by --rewrite-config" | ||
|
||
# Since we ran a container, there'll be leftover files in GRAPHROOT to clean up | ||
CONTAINERS_STORAGE_CONF=$STORAGE_CONF2 run_podman system reset --force | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
# vim: filetype=sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).