Skip to content

Conversation

@weirdwiz
Copy link
Collaborator

This command lets the user run a command in a new user namespace like unshare -u.
It uses the implementation of unshare in buildah. ( fixes #1388 )

@openshift-ci-robot
Copy link
Collaborator

Hi @weirdwiz. Thanks for your PR.

I'm waiting for a containers or openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 18, 2019
@vrothberg
Copy link
Member

/ok-to-test
/approve

@openshift-ci-robot openshift-ci-robot added ok-to-test approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 18, 2019
@rh-atomic-bot
Copy link
Collaborator

Can one of the admins verify this patch?
I understand the following commands:

  • bot, add author to whitelist
  • bot, test pull request
  • bot, test pull request once

@vrothberg
Copy link
Member

Hi @weirdwiz, thanks for the contribution!

I did not check the code yet but we also need to add a man page and bash completions for the new command.

@rhatdan
Copy link
Member

rhatdan commented Apr 18, 2019

Need update commands.md

@rhatdan
Copy link
Member

rhatdan commented Apr 18, 2019

Would be nice to have some tests too if possible

Copy link
Member

Choose a reason for hiding this comment

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

PODMAN does not have an ISOLATION type, I think this code can be dropped?
@giuseppe Do you agree?

Copy link
Member

Choose a reason for hiding this comment

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

yes, correct

@weirdwiz
Copy link
Collaborator Author

I see I'll add the man pages, bash completions and update the commands.md

Sure @rhatdan I'll make some tests.

Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

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

A few usability notes.

Also: what is the expected/desired behavior when run as root? I get:

ERRO[0000] error reading allowed ID mappings: error reading subuid mappings for user "root" and subgid mappings for group "root": No subuid ranges found for user "root" in /etc/subuid

Copy link
Member

Choose a reason for hiding this comment

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

Should be: "unshare [flags] [COMMAND [ARG...]]" to better indicate usage.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps more helpful as "no command specified, and $SHELL undefined"

Copy link
Member

Choose a reason for hiding this comment

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

Why the leading newline?

Copy link
Member

Choose a reason for hiding this comment

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

why exit with a 1? And the return following?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It exits with a 1 because ExecRunnable() exits with the exit status of the command, so if the control returns back to the function, it is definitely an error. The return nil is unnecessary I have now removed it.

Copy link
Member

Choose a reason for hiding this comment

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

is there no error handling here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function does not return anything and automatically exits depending on the exit code of the command run.

Copy link
Member

Choose a reason for hiding this comment

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

why not return an error

Copy link
Member

Choose a reason for hiding this comment

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

return an error?

Copy link
Member

Choose a reason for hiding this comment

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

does this need to be added to the remote client?

Copy link
Member

Choose a reason for hiding this comment

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

Probably not - only makes sense on a local machine, it spawns a fresh terminal in the userns.

Copy link
Member

Choose a reason for hiding this comment

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

Definitely not.

Copy link
Member

Choose a reason for hiding this comment

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

ok, then the command should not go in main. it needs to be added to the commands.go instead so it only shows up for the local client.

@giuseppe
Copy link
Member

we need to re-use the unshare implementation of Podman, where we join the existing namespace if it already exists. This should happen automatically if you just implement unshare to setup the shell or execute the specified command without caring of setting up the userns.

Copy link
Member

Choose a reason for hiding this comment

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

yes, correct

Copy link
Member

Choose a reason for hiding this comment

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

if you drop this line, would podman setup the namespace automatically?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, It sets up the namespace automatically, If I remove this line.

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L and removed size/M needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 21, 2019
@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L labels Apr 21, 2019
@weirdwiz weirdwiz force-pushed the master branch 2 times, most recently from cdc0035 to 006a2f7 Compare April 26, 2019 14:26
@mheon
Copy link
Member

mheon commented Apr 30, 2019

The unshare-specific test seems to be failing, and I'd like a head nod from @giuseppe - but otherwise this seems good to go.

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago, vrothberg, weirdwiz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@mheon
Copy link
Member

mheon commented May 2, 2019

Might push this to 1.4 so @giuseppe can give an ack

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #3039) made this pull request unmergeable. Please resolve the merge conflicts.

@weirdwiz
Copy link
Collaborator Author

weirdwiz commented May 3, 2019

Rebased

@rhatdan
Copy link
Member

rhatdan commented May 3, 2019

I have no idea why this is failing, and the logs seem to be useless.

You might need to add
podmanTest.CgroupManager = "cgroupfs"
podmanTest.StorageOptions = ROOTLESS_STORAGE_OPTIONS

But I am not sure.
@giuseppe @baude PTAL
These tests pass for me when run locally.

@giuseppe
Copy link
Member

giuseppe commented May 9, 2019

we should disable the tests when running as remote with SkipIfRemote().

@weirdwiz can you please take care of it?

@weirdwiz weirdwiz force-pushed the master branch 2 times, most recently from 5565730 to 4833b00 Compare May 9, 2019 16:33
@weirdwiz
Copy link
Collaborator Author

weirdwiz commented May 9, 2019

@giuseppe I have added SkipIfRemote() now

@giuseppe
Copy link
Member

could you please rebase?

This command lets the user run a command in a new user namespace like `unshare -u`.
It uses the implementation of unshare in buildah. ( fixes containers#1388 )

Signed-off-by: Divyansh Kamboj <[email protected]>
@giuseppe
Copy link
Member

tests are happy. LGTM

@vrothberg
Copy link
Member

Nice work, @weirdwiz!
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 16, 2019
@openshift-merge-robot openshift-merge-robot merged commit 2bb1487 into containers:master May 16, 2019
@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 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 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. ok-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFE: Need to add a podman unshare (Same as buildah unshare)

10 participants