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 ipc namespace modes "none, private, sharable" #13583

Merged
merged 1 commit into from
Apr 16, 2022

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Mar 21, 2022

Fixes: #13265

Signed-off-by: Daniel J Walsh [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 Mar 21, 2022
@rhatdan
Copy link
Member Author

rhatdan commented Mar 21, 2022

@mheon Currently we don't record the IPCMode of a container, but in order to get --ipcmod=private to work properly, we need to check if the container we are trying to share IPCMode with is marked as private, and then reject the connection.

How would you like me to record this information? Should we just add it to the config?

@rhatdan rhatdan changed the title Add support for ipc namespace modes "none, private, sharable" [wip] Add support for ipc namespace modes "none, private, sharable" Mar 21, 2022
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 21, 2022
@rhatdan
Copy link
Member Author

rhatdan commented Mar 21, 2022

Requires: containers/common#972

@mheon
Copy link
Member

mheon commented Mar 21, 2022

Why do we need to record it? For other namespaces we just reverse-engineer it from the OCI spec

@rhatdan
Copy link
Member Author

rhatdan commented Mar 22, 2022

I don't think they can regenerate it from the spec. "private" means that the container can not be shared with another container. There is nothing in the spec to indicate this as different then "sharable".

@@ -134,9 +135,13 @@ func namespaceOptions(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.
if err != nil {
return nil, errors.Wrapf(err, "error looking up container to share ipc namespace with")
}
if ipcCtr.Config().IPCMode.IsPrivate() {
Copy link
Member

Choose a reason for hiding this comment

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

Should use .ConfigNoCopy() or however this function was called.

@mheon
Copy link
Member

mheon commented Mar 22, 2022

@rhatdan If the only thing we're worried about is shareable IPC, I think a *bool would be good? Nil = use what's in the OCI spec, true = create a shareable private IPC namespace, false = create a non-shareable private IPC namespace.

@mheon
Copy link
Member

mheon commented Mar 22, 2022

Actually, I wonder if we even need the 3 states. Just a bool is probably file - false will be "use what was set in the OCI spec", true will be "configure a shareable, private IPC namespace"/

@rhatdan rhatdan changed the title [wip] Add support for ipc namespace modes "none, private, sharable" Add support for ipc namespace modes "none, private, sharable" Mar 22, 2022
@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 Mar 22, 2022
@rhatdan
Copy link
Member Author

rhatdan commented Mar 22, 2022

@mheon We care about whether the IPC Mode was none as well. Sharable, Private, None. I think we end up being Mode, so I am not sure why we don't just record it.

@mheon
Copy link
Member

mheon commented Mar 22, 2022

None is easy, just check that the bool is false (not creating shareable IPC) and the IPC namespace is missing from the OCI spec

- **ns:**_path_: path to an IPC namespace to join.
- **private**: private IPC namespace.
= **shareable**: private IPC with a possibility to share it with other containers.
Copy link
Member

Choose a reason for hiding this comment

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

see prior

@rhatdan rhatdan force-pushed the ipc branch 2 times, most recently from 1e12746 to f3c7883 Compare March 23, 2022 17:13
@rhatdan
Copy link
Member Author

rhatdan commented Mar 24, 2022

@mheon None does not mean don't create the IPC namespace, it means create the ipc namespace but don't mount tmpfs on /dev/shm. --ipc=host means don't create the ipc namespace. Thus we have to save the mode.

@mheon
Copy link
Member

mheon commented Mar 24, 2022

Then we probably want a separate "NoCreateSHM" bool. I really do not want to store the literal mode in the DB, we did that with network and it has not worked out well for us - string-comparing against a user-provided string in the DB to determine what mode we are in is complicated.

@rhatdan
Copy link
Member Author

rhatdan commented Mar 24, 2022

Do you want noshareshm, which would indicate what we are doing. We still could not tell the difference in the podman contanier inspect though. Or do you want two booleans.

@mheon
Copy link
Member

mheon commented Mar 24, 2022

@rhatdan Two bools, one for "do not create any SHM", one for "create a shareable SHM"

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 28, 2022
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 28, 2022
@rhatdan rhatdan force-pushed the ipc branch 3 times, most recently from 85bf788 to 3478fe3 Compare March 30, 2022 13:05
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 openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 8, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 8, 2022

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@giuseppe
Copy link
Member

giuseppe commented Apr 8, 2022

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 8, 2022
a private IPC namespace.

- "": Use Podman's default, defined in containers.conf.
- **container:**_id_: reuses another container's shared memory, semaphores, and message queues
Copy link
Member

Choose a reason for hiding this comment

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

nit

Suggested change
- **container:**_id_: reuses another container's shared memory, semaphores, and message queues
- **container:**_id_: reuses another container's shared memory, semaphores, and message queues.

@@ -528,9 +528,13 @@ To specify multiple static IPv6 addresses per container, set multiple networks u
Set the IPC namespace mode for a container. The default is to create
a private IPC namespace.

- "": Use Podman's default, defined in containers.conf.
- **container:**_id_: reuses another container shared memory, semaphores and message queues
Copy link
Member

Choose a reason for hiding this comment

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

same period nit

@TomSweeneyRedHat
Copy link
Member

A couple of missing periods that can be addressed later. LGTM, but I would like a head nod from @mheon as he had a couple of comments in previous passes.

@mheon
Copy link
Member

mheon commented Apr 8, 2022

Will review after lunch

} else if ctrSpec.Linux != nil {
switch {
case !c.config.ShmShare:
hostConfig.IpcMode = "private"
Copy link
Member

Choose a reason for hiding this comment

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

Won't this be true for ipc=container: as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

ShmShare would be set for them.

// ShmShare indicates whether /dev/shm can be shared with other containers
ShmShare bool `json:"ShmShare,omitempty"`
// ShmMount indicates whether a tmpfs should be created and mounted on /dev/shm
ShmMount bool `json:"ShmMount,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

This could break old containers, which won't have this set to true - maybe NoShmMount instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mheon How about now?

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 12, 2022
@mheon
Copy link
Member

mheon commented Apr 16, 2022

/lgtm
/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 16, 2022
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 16, 2022
@openshift-merge-robot openshift-merge-robot merged commit 8d3075e into containers:main Apr 16, 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.

--ipc parameters differ from Docker, lack none option
6 participants