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 handling of tmpfs-mode for tmpfs creation in compat mode #13455

Merged
merged 1 commit into from
Mar 9, 2022

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Mar 8, 2022

The permissions on disk were wrong since we were not converting to
octal.

Fixes: #13108

[NO NEW TESTS NEEDED] Since we don't currently test using the docker
client

Signed-off-by: Daniel J Walsh [email protected]

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 8, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 /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 Mar 8, 2022
@mheon
Copy link
Member

mheon commented Mar 8, 2022 via email

@rhatdan
Copy link
Member Author

rhatdan commented Mar 8, 2022

@nalind @jwhonce Any idea why the tests is failing. If I run the inspect with Docker, everything looks perfect.

@TomSweeneyRedHat
Copy link
Member

Changes LGTM
@edsantiago did the test fedora-35 test just time out? I don't see any error except this at the tail end:

[+0136s] ok 1050 [70-short-names] DELETE images/localhost/foo:tag : status=200
[+0136s] ok 1051 [70-short-names] DELETE containers/b98466f8386b19521d2c2a5fad045b2a5b02d595ada8956e1a086ba4f9331795 : status=204
[+0137s] ok 1052 [70-short-names] DELETE images/localhost/bar:latest : status=200
[+0137s] rootdir: /tmp/test-apiv2.tmp.Fq6omo
[+0140s] 1..1052
[+0140s] make: *** [Makefile:628: localapiv2] Error 1
[14:07:13] END - [+0140s] total duration since 2022-03-08T14:07:13

@edsantiago
Copy link
Member

edsantiago commented Mar 8, 2022

It's a real error. Look at the colorized log.

[EDIT: by "error" I mean "Dan fixed a real bug, and the test itself was actually broken"]

@rhatdan
Copy link
Member Author

rhatdan commented Mar 8, 2022

Yes it is a real error but I can not understand how it is happening. When I run all of the tests with DOCKER_HOST docker, everything works correctly, If I inspect the container it looks correct. This only seems to be happening with the API.
This looks like another conversion error, and maybe docker converts it back to correct.

DOCKER_HOST=unix:///run/user/3267/podman/podman.sock docker run -it --mount=type=tmpfs,dst=/xxx,tmpfs-size=1G,tmpfs-mode=755 debian ls -ld /xxx
drwxr-xr-x. 2 root root 40 Mar  8 17:08 /xxx
$ DOCKER_HOST=unix:///run/user/3267/podman/podman.sock docker inspect --format '{{.HostConfig.Tmpfs}}' d1e695e4643f
map[/xxx:size=1073741824,mode=755,rw,rprivate,nosuid,nodev,tmpcopyup]

@edsantiago
Copy link
Member

Oh! Sorry, the bug is here:

payload='{"Mounts":[{"Type":"tmpfs","Target":"/mnt/scratch","TmpfsOptions":{"SizeBytes":1024,"Mode":755}}]}'

The 755 is decimal, which is wrong. I don't know how to fix it, though: changing it to 0755 yields a JSON error. This is a problem for a JSON expert.

@edsantiago
Copy link
Member

sigh

index cc5eda88e..49f8fb3fc 100644
--- a/test/apiv2/20-containers.at
+++ b/test/apiv2/20-containers.at
@@ -394,7 +394,8 @@ t GET containers/$cid/json 200 \
   .Config.Healthcheck.Retries=3
 
 # compat api: Test for mount options support
-payload='{"Mounts":[{"Type":"tmpfs","Target":"/mnt/scratch","TmpfsOptions":{"SizeBytes":1024,"Mode":755}}]}'
+# Sigh, JSON can't handle octal. 0755(octal) = 493(decimal)
+payload='{"Mounts":[{"Type":"tmpfs","Target":"/mnt/scratch","TmpfsOptions":{"SizeBytes":1024,"Mode":493}}]}'
 t POST containers/create Image=$IMAGE HostConfig="$payload" 201 .Id~[0-9a-f]\\{64\\}
 cid=$(jq -r '.Id' <<<"$output")
 t GET containers/$cid/json 200 \

@edsantiago
Copy link
Member

Or, final thought for the day: maybe there's a way to make this code smarter about recognizing its input?

case "tmpfs-mode":
if len(kv) == 1 {
return newMount, errors.Wrapf(optionArgError, kv[0])
}
newMount.Options = append(newMount.Options, fmt.Sprintf("mode=%s", kv[1]))

The permissions on disk were wrong since we were not converting to
octal.

Fixes: containers#13108

[NO NEW TESTS NEEDED] Since we don't currently test using the docker
client

Signed-off-by: Daniel J Walsh <[email protected]>
Copy link
Member

@ashley-cui ashley-cui left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 9, 2022
@openshift-merge-robot openshift-merge-robot merged commit 4e21acd into containers:main Mar 9, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman system service fails to honour tmpfs permissions requested by docker cli over socket
6 participants