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

Add support for pod inside of user namespace. #10589

Merged
merged 1 commit into from
Aug 10, 2021

Conversation

umohnani8
Copy link
Member

Add the --userns flag to podman pod create and keep
track of the userns setting that pod was created with
so that all containers created within the pod will inherit
that userns setting.

Specifically we need to be able to launch a pod with
--userns=keep-id

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 7, 2021
@umohnani8
Copy link
Member Author

umohnani8 commented Jun 7, 2021

@rhatdan @giuseppe PTAL
For now only keep-id and host are working. There are some issues with auto that I am looking into.

@rhatdan
Copy link
Member

rhatdan commented Jun 7, 2021

I applied this to the master branch and I am getting weird errors?

$. /bin/podman pod create --userns=keep-id --name dan1
ERRO[0000] Error freeing pod lock after failed creation: no such file or directory
Error: error adding Infra Container: please set User explicitly via WithUser() instead of in OCI spec directly: invalid argument

@umohnani8
Copy link
Member Author

@rhatdan should be fixed now. I rebased before pushing it up and didn't realise the rebase broke it xD

@rhatdan
Copy link
Member

rhatdan commented Jun 8, 2021

Still looks like it does not work, and tests are not happy.

$ ./bin/podman pod create --userns=keep-id --name dan1
cb862419ce6a0b79b5876cbe32e2acad8cefb90d99ccfdd8864f828da5134f96
$ ./bin/podman run --pod dan1 fedora id
ERRO[0000] error starting some container dependencies   
ERRO[0000] "open /proc/sys/net/ipv4/ping_group_range: Permission denied: OCI permission denied" 
Error: error starting some containers: internal libpod error

pkg/specgen/generate/namespaces.go Outdated Show resolved Hide resolved
@rhatdan
Copy link
Member

rhatdan commented Jun 16, 2021

Fixes: #7706

@umohnani8 umohnani8 changed the title Add support for pod inside of user namespace. [WIP] Add support for pod inside of user namespace. Jun 23, 2021
@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 23, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 25, 2021
@umohnani8 umohnani8 force-pushed the pod-userns branch 6 times, most recently from e6285e7 to d8580f9 Compare June 30, 2021 14:50
@umohnani8 umohnani8 changed the title [WIP] Add support for pod inside of user namespace. Add support for pod inside of user namespace. Jun 30, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 30, 2021
@umohnani8
Copy link
Member Author

This is ready now. @rhatdan @mheon @giuseppe PTAL

@rhatdan
Copy link
Member

rhatdan commented Jun 30, 2021

Tests are not happy?

@rhatdan
Copy link
Member

rhatdan commented Jun 30, 2021

Code looks good and tests look great.

@rhatdan
Copy link
Member

rhatdan commented Aug 4, 2021

@vrothberg @umohnani8 Could this be a runc versus crun issue?

@vrothberg
Copy link
Member

@vrothberg @umohnani8 Could this be a runc versus crun issue?

Probably but I had to read the code in detail. @giuseppe does the below error sound familiar to you?

podman [options] run --pod testPod0 quay.io/libpod/alpine:latest cat /proc/self/uid_map
Error: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "sysfs" to rootfs at "/sys" caused: mount through procfd: operation not permitted: OCI permission denied

@giuseppe
Copy link
Member

giuseppe commented Aug 5, 2021

how does the generated config.json file look like with the failing test?

@giuseppe
Copy link
Member

giuseppe commented Aug 5, 2021

I see it generates:

    "namespaces": [
      {
        "type": "pid"
      },
      {
        "type": "network",
        "path": "/proc/122177/ns/net"
      },
      {
        "type": "ipc",
        "path": "/proc/122177/ns/ipc"
      },
      {
        "type": "uts",
        "path": "/proc/122177/ns/uts"
      },
      {
        "type": "mount"
      },
      {
        "type": "cgroup"
      },
      {
        "type": "user"
      }
    ],

The user namespace should also have the path set to the infraContainer as for the network, ipc and uts namespaces.

@umohnani8 umohnani8 force-pushed the pod-userns branch 2 times, most recently from 566fc8b to 2389e84 Compare August 5, 2021 18:07
Add the --userns flag to podman pod create and keep
track of the userns setting that pod was created with
so that all containers created within the pod will inherit
that userns setting.

Specifically we need to be able to launch a pod with
--userns=keep-id

Signed-off-by: Daniel J Walsh <[email protected]>
Signed-off-by: Urvashi Mohnani <[email protected]>
@umohnani8
Copy link
Member Author

Tests are finally passing now, can I please get some reviews here @rhatdan @mheon @giuseppe

Copy link
Member

@giuseppe giuseppe 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
Copy link
Contributor

openshift-ci bot commented Aug 10, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, rhatdan, umohnani8

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:
  • OWNERS [giuseppe,rhatdan,umohnani8]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Aug 10, 2021

/lgtm
Congratulations @umohnani8 I started working on this last November, and you finally pushed it over the finish line. Great work.
This was a very difficult problem.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 10, 2021
@openshift-ci openshift-ci bot merged commit e136ad4 into containers:main Aug 10, 2021
@rlpowell
Copy link

Thank you so much!

As a Fedora user, how can I track when this will be available there? Without pulling down pre-release packages, I mean.

@rhatdan
Copy link
Member

rhatdan commented Aug 12, 2021

podman 3.4 or later, we missed the cut, I believe for podman 3.3.

@francoism90
Copy link

Has this been removed? I'm keep getting:

Error: --userns and --pod cannot be set together

podman version 4.4.4

@giuseppe
Copy link
Member

Error: --userns and --pod cannot be set together

this is a different error. If you are joining an existing user namespace (with --pod), you cannot also create a new one with --userns

@francoism90
Copy link

@giuseppe Thanks for your reply and sorry for posting on the wrong PR.

If I understand correctly, and this to work, is to use idsmapping instead, right?

@giuseppe
Copy link
Member

it depends, not sure what you'd like to get. What is the expectation you've from the command you've used?

Were you trying to create a new user namespace?

@rhatdan
Copy link
Member

rhatdan commented Apr 17, 2023

The container you are adding is going to join the pod's user namespace. We don't allow containers inside of the same pod to run with different user namespaces, because too much stuff will break in unexpected ways.

@francoism90
Copy link

francoism90 commented Apr 17, 2023

@giuseppe @rhatdan I'm using podman-compose up, this uses the create command automatically it seems.

I want to access files from my host inside the container, using the same host user (id 1000).

@rhatdan
Copy link
Member

rhatdan commented Apr 17, 2023

If you are using podman-compose you should bring the issue up there.

@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 1, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 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.

9 participants