-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 handling of --read-only-tmpfs flag #20235
Conversation
@@ -1120,10 +1120,12 @@ EOF | |||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm --read-only=false $IMAGE touch /testrw | |||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm $IMAGE touch /tmp/testrw | |||
for dir in /tmp /var/tmp /dev /dev/shm /run; do | |||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman 1 run --rm --read-only-tmpfs=false $IMAGE touch $dir/testro |
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.
These are such confusing options. I don't have the brainpower to review right now, so just two quick points:
- for those who care, this is a breaking change
- for completeness, should we check all permutations of
--read-only
with--read-only-tmpfs
?
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.
The breaking change would have been to change the --read-only-tmpfs to --read-write-tmpf, which it is called internally. The issue is that if the user actually sets the constant it does it backwards, While if the user never sets it the default is to have read-write-tmpfs.
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.
Bottom line is the bug --read-only-tmpfs=false Was turning on read-only-tmpfs while --read-only-tmfs=true was turning off read-only-tmpfs.
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 man page must mention relation between these two flags.
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.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe, rhatdan 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 |
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.
Even with fresh morning brain, this is still way too confusing for me, so I'm not blocking but can you please check my comments?
Also, what @flouthoc said. The man page, IMO, only makes things worse as it is.
cmd/podman/common/create.go
Outdated
@@ -383,8 +383,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions, | |||
"read-only", podmanConfig.ContainersConfDefaultsRO.Containers.ReadOnly, | |||
"Make containers root filesystem read-only", | |||
) | |||
createFlags.BoolVar( | |||
&cf.ReadWriteTmpFS, | |||
createFlags.Bool( | |||
"read-only-tmpfs", cf.ReadWriteTmpFS, | |||
"When running containers in read-only mode mount a read-write tmpfs on /run, /tmp and /var/tmp", |
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 realize this is not part of your PR, but this description seems absolutely wrong and misleading. It seems to apply to the variable name, not the option name. (Also, missing comma between "mode" and "mount").
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm --read-only=false $IMAGE touch $dir/testro | ||
CONTAINERS_CONF_OVERRIDE="$containersconf" run_podman run --rm --read-only=false --read-only-tmpfs=true $IMAGE touch $dir/testro |
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.
This seems wrong to me? If I ask for read-only-tmpfs
, I want a read-only tmpfs.
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 added the table to the docs. --read-only=true is required in order to add the --read-only-tmpfs=true.
Code LGTM, but I'll refrain from merging until Ed's comments are answered |
72a128d
to
baaf5af
Compare
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.
This is straight up breaking as it inverts the meaning of that option, as confusing as the name might be the doc is clear the setting --read-only-tmpfs
mounts rw.
We cannot just break every user of that option just because the name is confusing.
My understanding of how this works from past behaviour of podman (pre-4.7) and the names of the flags is:
The current 4.7 behaviour the results of the first two lines are swapped. The description of the --tmpfs-read-only is confusing. Something like this may be clearer: "Given --read-only being true should default tmpfs mounts (/tmp, /run, /dev, etc) also be read-only? (default: false)" Currently all my ansible is broken under 4.7 as it relied on previous behaviour. (from memory the default pre-4.7 was to make the default tmpfs mounts r/w) |
There is no --tmpfs-read-only it is called --read-only-tmpfs. I see no difference between main, 4.7.0 or 4.6.2 or 4.3.1 (prior to 338b283) when checking /tmp mount points. Your problem seems to be special to the /dev mount As confusing as the current name might be we should not break the behaviour as this will just break every users of this option so this PR is incorrect IMO. |
Ok the current code looks correct.
The table should be:
In True|True additional tmpfs are mounted on /tmp, /run, and /var/tmp In all other cases, the /dev and /dev/shm are read/write and the /tmp, /run, and /var/tmp are not modified. |
8e2b8f7
to
b5f4d9b
Compare
Ephemeral COPR build failed. @containers/packit-build please check. |
Cockpit tests failed for commit b5f4d9bb623d61df9ea713eb219c7190ab724761. @martinpitt, @jelly, @mvollmer please check. |
@Luap99 @edsantiago @vrothberg I think this is fixed now PTAL. |
cmd/podman/containers/create.go
Outdated
if cmd.Flags().Changed("read-only-tmpfs") { | ||
cliVals.ReadWriteTmpFS, err = flags.GetBool("read-only-tmpfs") | ||
if err != nil { | ||
return err | ||
} | ||
} |
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.
This change seems unnecessary, you can just keep the flag definition as BoolVar().
When --read-only=True and --read-only-tmpfs=True additional tmpfs are mounted on | ||
the /tmp, /run, and /var/tmp directories. | ||
|
||
When --read-only=True and --read-only-tmpfs=False /dev and /dev/shm are marked | ||
Read/Only and no tmpfs are mounted on /tmp, /run and /var/tmp. The directories | ||
are exposed from the underlying image, meaning they are read-only by default. | ||
|
||
In all other cases where --read-only=false the /dev and /dev/shm are read/write and the /tmp, /run, and /var/tmp are not mounted over by default. |
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 seems to be common style to put command and flags into bold blocks in all man pages, i.e. **--read-only**
I also find it weird to use the upper case True/False, I think we generally stick to the lowercase versions everywhere.
And lastly the last sentence doesn't look right grammatically to me. I am not a native speaker of course but without extra context I don't think I am able to understand this.
Cockpit tests failed for commit 0b09cf8862a2d8c0c4969ab2f77913d58e34fe10. @martinpitt, @jelly, @mvollmer please check. |
Cockpit tests failed for commit 0cdc2f867bf570e60e521566a69a03db6a345b92. @martinpitt, @jelly, @mvollmer please check. |
@TomSweeneyRedHat @Luap99 PTAL |
Can you please squash the second commit. |
Fixes: containers#20225 Signed-off-by: Daniel J Walsh <[email protected]>
Post merge, but LGTM |
Fixes: #20225
Does this PR introduce a user-facing change?