[kata-dev] kata-agent RemoveContainer timeout buggy?
Stefan Hajnoczi
stefanha at redhat.com
Fri Nov 9 10:46:36 UTC 2018
It looks like the goroutine will be left running when kata-agent
RemoveContainer() returns after a timeout. In addition, the sandbox
lock is no longer held so any actions taken by the goroutine could cause
problems.
Am I understanding the code correctly?
func (a *agentGRPC) RemoveContainer(ctx context.Context, req *pb.RemoveContainerRequest) (*gpb.Empty, error) {
...
timeout := int(req.Timeout)
a.sandbox.Lock()
defer a.sandbox.Unlock()
if timeout == 0 {
...
} else {
done := make(chan error)
go func() {
if err := ctr.removeContainer(); err != nil {
done <- err
close(done)
return
}
//Find the sandbox storage used by this container
for _, path := range ctr.mounts {
if _, ok := a.sandbox.storages[path]; ok {
if err := a.sandbox.unsetAndRemoveSandboxStorage(path); err != nil {
done <- err
close(done)
return
}
}
}
close(done)
}()
select {
case err := <-done:
if err != nil {
return emptyResp, err
}
case <-time.After(time.Duration(req.Timeout) * time.Second):
return emptyResp, grpcStatus.Errorf(codes.DeadlineExceeded, "Timeout reached after %ds", timeout)
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: not available
URL: <http://lists.katacontainers.io/pipermail/kata-dev/attachments/20181109/b3bd3e07/attachment.sig>
More information about the kata-dev
mailing list