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

sigproxy: return after closing the channel #5036

Merged
merged 1 commit into from Jan 31, 2020

Conversation

vrothberg
Copy link
Member

When stopping signal handling (e.g., to properly handle ^C) we are also
closing the signal channel. We should really return from the go-routine
instead of continuing and risking double-closing the channel which leads
to a panic.

Fixes: #5034
Signed-off-by: Valentin Rothberg rothberg@redhat.com

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS labels Jan 31, 2020
@@ -30,6 +30,7 @@ func ProxySignals(ctr *libpod.Container) {
if err := syscall.Kill(syscall.Getpid(), s.(syscall.Signal)); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Wait, what is this even doing? Why are we double-sending the signal to ourself on errors?

Copy link
Member

Choose a reason for hiding this comment

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

From git-blame, it looks like an attempt to make C-c kill Podman if sig-proxy fails because the container is stopped. I don't know if this is a good idea, or necessary at all, but it's probably not harmful

Copy link
Member Author

Choose a reason for hiding this comment

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

I had the very same question and found https://github.com/containers/libpod/pull/1086/files#r202198031.

Copy link
Member Author

Choose a reason for hiding this comment

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

But I am not sure about the correctness after all

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 this be the container?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes (some) sense to me as is — as long as the container is running, attempts to gracefully terminate Podman are redirected to gracefully terminating the container. (The downside is that if the container is uncooperative, it’s difficult to terminate Podman.)

If the container dies, and we find out here, we need to forward that one signal to ourselves so that it is not lost, and then we terminate the proxy and let the defaults play out.

(Pedantically, at the time of StopCatch, several other signals may be queued in sigBuffer, and we throw them away. For the typical SIGINT/SIGTERM case this doesn’t matter much.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Tests are green now. Mind dropping a LGTM if you agree to the changes?

@mheon
Copy link
Member

mheon commented Jan 31, 2020

LGTM

@TomSweeneyRedHat
Copy link
Member

Could we add a comment similar to Miloslav's in the code to avoid future head scratching?
Otherwise LGTM

Copy link
Collaborator

@mtrmac mtrmac 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-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mtrmac, vrothberg

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

When stopping signal handling (e.g., to properly handle ^C) we are also
closing the signal channel.  We should really return from the go-routine
instead of continuing and risking double-closing the channel which leads
to a panic.

Fixes: containers#5034
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
@vrothberg
Copy link
Member Author

Could we add a comment similar to Miloslav's in the code to avoid future head scratching?
Otherwise LGTM

Good point! I added a comment a repushed.

@TomSweeneyRedHat
Copy link
Member

LGTM, thanks for the comment.

@rhatdan
Copy link
Member

rhatdan commented Jan 31, 2020

/lgtm
/hold
hold cancel once tests pass.

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Jan 31, 2020
@vrothberg
Copy link
Member Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 31, 2020
@openshift-merge-robot openshift-merge-robot merged commit 781fc82 into containers:master Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman run --rm : Error forwarding signal 23 to container, plus stacktrace
7 participants