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

kill: allow to signal paused containers #1943

Conversation

giuseppe
Copy link
Member

regression introduced by 87a1889

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com

regression introduced by 87a1889

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@cyphar
Copy link
Member

cyphar commented Dec 1, 2018

The reason why we excluded Paused is because the runtime-spec explicitly states that

Attempting to send a signal to a container that is neither created nor running MUST have no effect on the container and MUST generate an error.

However the runtime spec doesn't support pause so it should be okay to add an extension to kill as well, so I'm somewhat LGTM.

@crosbymichael WDYT?

@Ace-Tang
Copy link
Contributor

Ace-Tang commented Dec 1, 2018

I get a question, from the original logic, function Signal send signal to all status container

if err := c.initProcess.signal(s); err != nil {
 		return newSystemErrorWithCause(err, "signaling init process")
}

so it also include Pausing status, the change 87a1889 fix to not kill stopped container. Now the pr add Paused status container, what about Pausing status container, should it also need to be add according to the original logic ?

@cyphar
Copy link
Member

cyphar commented Dec 1, 2018

Pausing is a transient state -- effectively it's just a state before we write FROZEN to the freezer cgroup. You wouldn't consistently be able to hit that race anyway. For analogy, we don't allow kill on containers which are in the Creating state either.

@lifubang
Copy link
Member

lifubang commented Dec 1, 2018

I have considered the paused state before I submitted the commit 87a1889 , I should tell the maintainer my thinking before the commit merged. My original thinking is that:
When we send the signal kill redis 9 to the container redis which is paussed, it tell us success, but when we use runc list, redis's state is also paused, we need to use runc resume redis, then it's state can transfer to stopped.
If there are two users look into container redis which is paused, one user A runc kill redis 9, aother user B use runc resume redis, the user B will be puzzle in the state stopped after resume.
That is my original idea.
So, I think both add or don't add paused are ok.

@giuseppe
Copy link
Member Author

giuseppe commented Dec 3, 2018

I've noticed the breaking change as we are using to signal a paused container in podman (to implement rm -f for paused containers) and one of our tests failed when using runc from master.

/cc @baude

@lifubang
Copy link
Member

lifubang commented Dec 3, 2018

@giuseppe For https://github.com/opencontainers/runtime-spec/blob/7c4c8f63a63693f75cfa0f3f397151fb8d9732ad/runtime.md#Kill

This operation MUST generate an error if it is not provided the container ID. Attempting to send a signal to a container that is neither created nor running MUST have no effect on the container and MUST generate an error. This operation MUST send the specified signal to the container process.

I think we may not add Paused.

But, I think, for https://github.com/opencontainers/runtime-spec/blob/7c4c8f63a63693f75cfa0f3f397151fb8d9732ad/runtime.md#state

running: the container process has executed the user-specified program but has not exited (after step 5 in the lifecycle)

I think Paused should belongs to Running.

So, I think to follow the runtime-spec standard, I think we may need to add a new function to check the containers status, for example:

func (s Status) RuntimeSpecStatus() Status {
	switch s {
	case Created:
		return Created
	case Running:
		return Running
	case Pausing:
		return Running
	case Paused:
		return Running
	case Stopped:
		return Stopped
	default:
		return nil
	}
}

Then, in

if status == Running || status == Created || status == Paused {
, we can use:

runtimeSpecStatus := status.RuntimeSpecStatus()
if runtimeSpecStatus == Running || runtimeSpecStatus == Created {

@@ -382,7 +382,7 @@ func (c *linuxContainer) Signal(s os.Signal, all bool) error {
return err
}
// to avoid a PID reuse attack
if status == Running || status == Created {
if status == Running || status == Created || status == Paused {
Copy link
Member

Choose a reason for hiding this comment

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

I think to follow runtime-spec standard, we can add a func to transfer runc container state to runtime-spec state.
Please see: #1943 (comment)

@cyphar
Copy link
Member

cyphar commented Dec 3, 2018

@lifubang You're over-complicating things -- runc has a few extensions to the runtime-spec and one of those is the pause operation and the paused state. It's really not necessary to have separate logic about "runtime spec states" and "runc states" -- libcontainer is already complicated enough as it is.

Given that paused is an extension to the spec, we can add it to other operations. The part of the spec that I quoted earlier (and you quoted) is only talking about the states defined in the spec. paused is not defined in the spec and thus we can make our own semantics for it.

As @giuseppe said this is a regression, so I'm okay with fixing this.

LGTM.

Approved with PullApprove

@cyphar cyphar added this to the 1.0.0 milestone Dec 3, 2018
@crosbymichael
Copy link
Member

crosbymichael commented Dec 3, 2018

LGTM

Approved with PullApprove

@crosbymichael crosbymichael merged commit 96ec217 into opencontainers:master Dec 3, 2018
giuseppe added a commit to giuseppe/libpod that referenced this pull request Dec 4, 2018
the regression we noticed in runc was fixed upstream:

opencontainers/runc#1943

so we can use again runc from master.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
giuseppe added a commit to giuseppe/libpod that referenced this pull request Dec 4, 2018
the regression we noticed in runc was fixed upstream:

opencontainers/runc#1943

so we can use again runc from master.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants