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 timeout while waiting for StartTransinetUnit completion signal #1754

Merged
merged 1 commit into from
Mar 8, 2018

Conversation

vikaschoudhary16
Copy link
Contributor

This PR adds one second timeout for waiting on channel for StartTransientUnit completion signal.

This channel was introduced to avoid a rare race between systemd and runc where systemd could delete pids cgroup created by runc. #1683

If for some reason signal is not received like the case here, runc will hang forever. Adding a timeout will help recover in such a case.

In the timeout handling, we have two options either return Error or continue. Since originally purpose of introducing channel was to avoid the race mentioned above, one second time duration should be enough in ensuring the same and to continue seems a better option of the two.

/cc @derekwaynecarr @sjenning

<-statusChan
select {
case <-statusChan:
case <-time.After(time.Second):
Copy link
Member

Choose a reason for hiding this comment

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

Should have some sort of warning at least. I would also recommend investigating why we don't get the status from systemd. In the issue you said:

Not sure how dbus works from within the containerized env or how we might fix this.

I'm not sure what containerised environment you're using, but dbus should be running as a daemon inside whatever container you're spawning runc inside as it normally would on your host. Can you reproduce the issue using runc on the host?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cyphar added warning.

what containerised environment ...

It occured in containerized OpenShift. I am trying to reproduce it on my local machine. Will update on that further.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the way this has worked in the past is that the origin node container runs as privileged, which implies a shared IPC and PID namespace with the host such that the containerized node can get dbus signals from the host dbus.

…om dbus

Signed-off-by: vikaschoudhary16 <choudharyvikas16@gmail.com>
@sjenning
Copy link
Contributor

sjenning commented Mar 7, 2018

@cyphar we are trying to run down the root cause, but in the meantime, I think we should merge this. Even if we get the dbus issue figured out, I'm not sure if we should consider dbus reliable. If, for whatever reason, it drops the message or systemd fails to send the signal we expect, we are still hung. Said another way, this probably should have never been an unconditional wait on the channel with no timeout.

Do you agree?

@mrunalp
Copy link
Contributor

mrunalp commented Mar 7, 2018

LGTM

Approved with PullApprove

@sjenning
Copy link
Contributor

sjenning commented Mar 7, 2018

@hqhq could we get lgtm on this since you approved the previous PR to which the fix applies?

@hqhq
Copy link
Contributor

hqhq commented Mar 8, 2018

LGTM

Approved with PullApprove

@hqhq hqhq merged commit 9facb87 into opencontainers:master Mar 8, 2018
@cyphar
Copy link
Member

cyphar commented Mar 8, 2018

@sjenning

If you don't want to worry about what systemd does then you can just not use the systemd cgroup code (the whole thing is questionable because by design it works around systemd's lack of support of things we need for runc -- not to mention we've had nothing but problems from it historically because systemd loves to mess with cgroups you tell it about through TransientUnits).

IMHO if there's a DBus reliability issue within containers -- which shouldn't be the case and if it is that's a pretty major problem to sweep under the rug -- then continuing to use the systemd cgroup code and ignoring the problem makes little more sense than just using the cgroupfs code. But you're free to do whatever you like. The obvious problem is that now that the problem is "fixed" it's less likely someone will be bothered enough to debug what the actual issue was.

@derekwaynecarr
Copy link
Contributor

i agree this should have had a timeout from its inception, i would like to understand the root cause.

openshift-merge-robot added a commit to openshift/origin that referenced this pull request Mar 8, 2018
Automatic merge from submit-queue.

[3.9] UPSTREAM: opencontainers/runc: 1754: Add timeout while waiting for StartTransinetUnit completion signal

master PR #18876

opencontainers/runc#1754

xref https://bugzilla.redhat.com/show_bug.cgi?id=1548358

Hold until upstream merge.

@derekwaynecarr @vikaschoudhary16
openshift-merge-robot added a commit to openshift/origin that referenced this pull request Mar 8, 2018
Automatic merge from submit-queue (batch tested with PRs 18778, 18709, 18876, 18897, 18652).

UPSTREAM: opencontainers/runc: 1754: Add timeout while waiting for StartTransinetUnit completion signal

opencontainers/runc#1754

xref https://bugzilla.redhat.com/show_bug.cgi?id=1548358

Hold until upstream merge.

@derekwaynecarr @vikaschoudhary16
filbranden added a commit to filbranden/runc that referenced this pull request Mar 31, 2018
The channel was introduced in opencontainers#1683 to work around a race condition.
However, the check for error in StartTransientUnit ignores the error for
an already existing unit, and in that case there will be no notification
from DBus (so waiting on the channel will make it hang.)

Later PR opencontainers#1754 added a timeout, which worked around the issue, but we
can fix this correctly by only waiting on the channel when there is no
error. Fix the code to do so.

The timeout handling was kept, since there might be other cases where
this situation occurs (https://bugzilla.redhat.com/show_bug.cgi?id=1548358
mentions calling this code from inside a container, it's unclear whether
an existing container was in use or not, so not sure whether this would
have fixed that bug as well.)
filbranden added a commit to filbranden/runc that referenced this pull request Apr 9, 2018
The channel was introduced in opencontainers#1683 to work around a race condition.
However, the check for error in StartTransientUnit ignores the error for
an already existing unit, and in that case there will be no notification
from DBus (so waiting on the channel will make it hang.)

Later PR opencontainers#1754 added a timeout, which worked around the issue, but we
can fix this correctly by only waiting on the channel when there is no
error. Fix the code to do so.

The timeout handling was kept, since there might be other cases where
this situation occurs (https://bugzilla.redhat.com/show_bug.cgi?id=1548358
mentions calling this code from inside a container, it's unclear whether
an existing container was in use or not, so not sure whether this would
have fixed that bug as well.)

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
filbranden added a commit to filbranden/runc that referenced this pull request Apr 14, 2018
So that, if a timeout happens and we decide to stop blocking on the
operation, the writer will not block when they try to report the result
of the operation.

This should address Issue opencontainers#1780 and it's a follow up for PR opencontainers#1683,
PR opencontainers#1754 and PR opencontainers#1772.
filbranden added a commit to filbranden/runc that referenced this pull request Apr 14, 2018
So that, if a timeout happens and we decide to stop blocking on the
operation, the writer will not block when they try to report the result
of the operation.

This should address Issue opencontainers#1780 and it's a follow up for PR opencontainers#1683,
PR opencontainers#1754 and PR opencontainers#1772.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
filbranden added a commit to filbranden/kubernetes that referenced this pull request Apr 24, 2018
PR opencontainers/runc#1754 works around an issue in manager.Apply(-1) that
makes Kubelet startup hang when using systemd cgroup driver (by adding a
timeout) and further PR opencontainers/runc#1772 fixes that bug by
checking the proper error status before waiting on the channel.

PR opencontainers/runc#1776 checks whether Delegate works in slices,
which keeps libcontainer systemd cgroup driver working on systemd v237+.

PR opencontainers/runc#1781 makes the channel buffered, so if we time
out waiting on the channel, the updater will not block trying to it
since there are no longer any consumers.
k8s-github-robot pushed a commit to kubernetes/kubernetes that referenced this pull request Apr 25, 2018
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Update libcontainer to include PRs with fixes to systemd cgroup driver

**What this PR does / why we need it**:

PR opencontainers/runc#1754 works around an issue in manager.Apply(-1) that makes Kubelet startup hang when using systemd cgroup driver (by adding a timeout) and further PR opencontainers/runc#1772 fixes that bug by checking the proper error status before waiting on the channel.
    
PR opencontainers/runc#1776 checks whether Delegate works in slices, which keeps libcontainer systemd cgroup driver working on systemd v237+.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #61474

**Special notes for your reviewer**:
/assign @derekwaynecarr
cc @vikaschoudhary16 @sjenning @adelton @mrunalp 

**Release note**:

```release-note
NONE
```
filbranden added a commit to filbranden/kubernetes that referenced this pull request Apr 25, 2018
PR opencontainers/runc#1754 works around an issue in manager.Apply(-1) that
makes Kubelet startup hang when using systemd cgroup driver (by adding a
timeout) and further PR opencontainers/runc#1772 fixes that bug by
checking the proper error status before waiting on the channel.

PR opencontainers/runc#1776 checks whether Delegate works in slices,
which keeps libcontainer systemd cgroup driver working on systemd v237+.

PR opencontainers/runc#1781 makes the channel buffered, so if we time
out waiting on the channel, the updater will not block trying to it
since there are no longer any consumers.
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.

6 participants