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

Handle potential timeouts when attempting to get the CNI lock #4666

Closed
lbernail opened this issue Oct 28, 2020 · 9 comments
Closed

Handle potential timeouts when attempting to get the CNI lock #4666

lbernail opened this issue Oct 28, 2020 · 9 comments
Labels
area/cri Container Runtime Interface (CRI)

Comments

@lbernail
Copy link

With two different CNI plugins (and for two very different problems with them) we have seen situations where a CNI operation never returns and hangs, never releasing the the CNI lock. I think it would be helpful to add a timeout to the tentatives to get the lock and surface meaningful errors to the kubelet.

Today when this happens the CRI status call from the kubelet will time out with this log:

 Status from runtime service failed: rpc error: code = DeadlineExceeded desc = context deadline exceeded

The kubelet will then mark the node as NotReady with Reason container runtime is down which is misleading because crictl pods and crictl ps continues to work perfectly (but crictl info doesn't because it also calls the CRI status method).

The containerd call in the Status method is here: https://github.com/containerd/cri/blob/master/pkg/server/status.go#L44-L49
And the libcni.Status method is here: https://github.com/containerd/go-cni/blob/master/cni.go#L124-L132

I think adding a timeout to https://github.com/containerd/go-cni/blob/master/cni.go#L126 and returning a different meaningful error would be helpful and make debugging easier when this happens.

The default kubelet timeout for this call is 2mn: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kubelet/config/v1beta1/types.go#L447-L453

So if we decide to this, we should probably use a shorter timeout (90s?).

I don't think sync/rwmutex supports timeouts so we'd need to use a different implementation. I'd be more than happy to help with a PR if you think it makes sense.

@AkihiroSuda AkihiroSuda transferred this issue from containerd/cri Oct 28, 2020
@AkihiroSuda
Copy link
Member

Transferred the issue from the old CRI repo github.com/containerd/cri

@AkihiroSuda AkihiroSuda added the area/cri Container Runtime Interface (CRI) label Oct 28, 2020
@fuweid
Copy link
Member

fuweid commented Nov 9, 2020

@lbernail which version of cri plugin are you using right now? I changed the logic that the CRI will not load the CNI plugin during Status call. containerd/cri#1405

@lbernail
Copy link
Author

lbernail commented Nov 9, 2020

@fuweid I saw this on 1.2 but I'm pretty sure it also impacts master because we still have this call:

if err := c.netPlugin.Status(); err != nil {

which tries to acquire the CNI lock in the CRI status handler

I'll reproduce with 1.4 to be sure

@fuweid
Copy link
Member

fuweid commented Nov 11, 2020

Any update? @lbernail

Both the c.netPlugin.Status() and c.netPlugin.Setup requires RLock. If there is no c.netPlugin.Load call, the RLock will not be impacted.

@lbernail
Copy link
Author

@fuweid Sorry for the delay. I just test with 1.4.1 and it works a lot better!

So the only potential problem now is that we can't reload the configuration if a RunPodSandbox call is holding a Rlock which is not a big deal I think.

Is this only available since 1.4?

Many thanks and sorry for the issue, I had misunderstood the locking logic here

@fuweid
Copy link
Member

fuweid commented Nov 18, 2020

@lbernail Yes. It is available since major release 1.4. :)

It is good to upgrade your containerd version ~

@lbernail
Copy link
Author

We will soon!
Quick follow-up question: do you think we should add timeouts to Add/Del calls? It will avoid the situation where the kubelet CRI call times out with a misleading message.
We could surface a clearer error message from containerd such as "CNI invocation timed out")

@fuweid
Copy link
Member

fuweid commented Nov 20, 2020

@lbernail I am going to close this issue. Please create new one if you have other questions. And thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cri Container Runtime Interface (CRI)
Projects
None yet
Development

No branches or pull requests

3 participants