[lxc-devel] [lxd/master] lxd/container_lxc: ensure Done() is always called

brauner on Github lxc-bot at linuxcontainers.org
Fri Dec 2 21:11:50 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 826 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161202/d49d4afa/attachment.bin>
-------------- next part --------------
From 42be346faa1bbb61f0d954cd13307ad48dc15378 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 2 Dec 2016 22:06:12 +0100
Subject: [PATCH] lxd/container_lxc: ensure Done() is always called

This commit ensures that we call Done() in all cases to actually report that the
operation is done. If I'm correct, this should fix any remaining hanging lxc
restart commands that are not explained by the fixes I pushed to liblxc.
A reproducer would be:

for i in {1..100}; do for c in foo{1..50}; do lxc restart $c & done; wait; done

A new enough liblxc version together with this commit in the LXD version should
not leave to any hanging commands.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/container_lxc.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 82a91d3..043e221 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -2145,12 +2145,14 @@ func (c *containerLXC) Shutdown(timeout time.Duration) error {
 
 	err = op.Wait()
 	if err != nil && c.IsRunning() {
+		op.Done(err)
 		shared.LogError("Failed shutting down container", ctxMap)
 		return err
 	}
 
 	shared.LogInfo("Shut down container", ctxMap)
 
+	op.Done(nil)
 	return nil
 }
 


More information about the lxc-devel mailing list