The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2499

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Only try to Freeze() or Stop() if the container is running. Otherwise we will
cause unnecessary errors when users e.g. reboot the container via

	lxc exec foo reboot

in which case the init systems does the work and we would be trying to
Freeze()/Stop() a container that is not running anymore.

Signed-off-by: Christian Brauner <christian.brau...@canonical.com>
From 5d719db0b3c4e1f23cba4a6e63e863f9a50cea62 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@canonical.com>
Date: Fri, 14 Oct 2016 11:59:37 +0200
Subject: [PATCH] lxd/container_lxc: check if container is running

Only try to Freeze() or Stop() if the container is running. Otherwise we will
cause unnecessary errors when users e.g. reboot the container via

        lxc exec foo reboot

in which case the init systems does the work and we would be trying to
Freeze()/Stop() a container that is not running anymore.

Signed-off-by: Christian Brauner <christian.brau...@canonical.com>
---
 lxd/container_lxc.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 830265d..49254c3 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -1690,6 +1690,11 @@ func (c *containerLXC) Stop(stateful bool) error {
                return err
        }
 
+       if !c.IsRunning() {
+               shared.LogDebug("Not stopping container as it is not running.", 
ctxMap)
+               return nil
+       }
+
        // Attempt to freeze the container first, helps massively with fork 
bombs
        c.Freeze()
 
@@ -1883,6 +1888,11 @@ func (c *containerLXC) Freeze() error {
                return err
        }
 
+       if !c.IsRunning() {
+               shared.LogDebug("Not freezing container as it is not running.", 
ctxMap)
+               return nil
+       }
+
        err = c.c.Freeze()
        if err != nil {
                ctxMap["err"] = err
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to