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

rootless netns: eval symlink for XDG_RUNTIME_DIR #14668

Closed
wants to merge 1 commit into from

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Jun 20, 2022

When we bind mount the old XDG_RUNTIME_DIR to the new fake /run it will
cause issues when the XDG_RUNTIME_DIR is a symlink since they do not
exists in the new path hierarchy. To fix this we can just follow the
symlink before we try to use the path.

Fixes #14606

Does this PR introduce a user-facing change?

Fixed a bug where the rootless netns could not be used when XDG_RUNTIME_DIR was set to /var/run... and this was a symlink to /run.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 20, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99

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 Jun 20, 2022

# NOTE: the --root/--runroot are required to force a new boltdb and not reuse old chached paths
XDG_RUNTIME_DIR="$NEW_XDG_RUNTIME_DIR" run_podman --root $PODMAN_TMPDIR/root --runroot $PODMAN_TMPDIR/runroot unshare --rootless-netns ip a
is "$output" ".*tap0.*" "slirp4netns interface exists in netns"
Copy link
Member

Choose a reason for hiding this comment

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

I just ran this against podman @ fe8e536 (main) and it passes. This suggests that you are not testing what you think you're testing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for checking. I think I have to actual run a container with netavark to trigger this problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should fail with main now and pass on this PR if netavark is used.

@mheon
Copy link
Member

mheon commented Jun 21, 2022

LGTM

@@ -134,6 +134,12 @@ func (r *RootlessNetNS) Do(toRun func() error) error {
if err != nil {
return errors.Wrap(err, "could not get runtime directory")
}
// eval symlinks since they may not exists in the new path: https://github.com/containers/podman/issues/14606
xdgRuntimeDir, err = filepath.EvalSymlinks(xdgRuntimeDir)
Copy link
Member

Choose a reason for hiding this comment

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

would it work to have the check once only in SetXdgDirs() instead of two different places?

Copy link
Member Author

Choose a reason for hiding this comment

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

That sounds good but we have to be careful not to break any existing systems.

@Luap99 Luap99 force-pushed the netns-evalsymlink branch from 6e37c47 to adda5fc Compare June 27, 2022 13:45
When we bind mount the old XDG_RUNTIME_DIR to the new fake /run it will
cause issues when the XDG_RUNTIME_DIR is a symlink since they do not
exists in the new path hierarchy. To fix this we can just follow the
symlink before we try to use the path.

This fix is kinda ugly, our XDG_RUNTIME_DIR code is all over the place.
We should work on consolidating this sooner than later.

Fixes containers#14606

Signed-off-by: Paul Holzinger <[email protected]>
@Luap99 Luap99 force-pushed the netns-evalsymlink branch from adda5fc to f5c3395 Compare June 27, 2022 13:45
@edsantiago
Copy link
Member

[+1361s] # $ podman run --network bridge --rm quay.io/libpod/testimage:20220615 ip a
[+1361s] # Error: failed to mount runtime directory for rootless netns: no such file or directory

I'm seeing the same failure on my f36 laptop.

@Luap99
Copy link
Member Author

Luap99 commented Jun 28, 2022

[+1361s] # $ podman run --network bridge --rm quay.io/libpod/testimage:20220615 ip a
[+1361s] # Error: failed to mount runtime directory for rootless netns: no such file or directory

I'm seeing the same failure on my f36 laptop.

I clearly do not understand the issue correctly, something very strange is happening here. It works for me the first time but when I rerun the it it fails.

@vrothberg
Copy link
Member

Ping (I am going through older PRs).

@Luap99
Copy link
Member Author

Luap99 commented Jul 28, 2022

Fixing it properly is more complicated, we have to start sharing the XDG code across the repos, c/common uses a different function than podman thus breaking the test here.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 30, 2022
@openshift-merge-robot
Copy link
Collaborator

@Luap99: 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/test-infra repository.

@github-actions
Copy link

A friendly reminder that this PR had no activity for 30 days.

@Luap99
Copy link
Member Author

Luap99 commented Nov 1, 2022

replaced by #15918

@Luap99 Luap99 closed this Nov 1, 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 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 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. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note stale-pr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IPAM error: failed to open database /run/user/1000/containers/networks/ipam.db
6 participants