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

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) ===

From a03d267d38fe3c66c725ebd671d0323cc1743451 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.ander...@canonical.com>
Date: Mon, 24 Oct 2016 18:33:32 +0000
Subject: [PATCH 1/2] also clean up apparmor stuff in OnStart when something
 fails

Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com>
---
 lxd/container_lxc.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 7170548..ff048d8 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -1569,6 +1569,7 @@ func (c *containerLXC) OnStart() error {
                // Run any template that needs running
                err = c.templateApplyNow(c.localConfig[key])
                if err != nil {
+                       AADestroy(c)
                        c.StorageStop()
                        return err
                }
@@ -1576,6 +1577,7 @@ func (c *containerLXC) OnStart() error {
                // Remove the volatile key from the DB
                err := dbContainerConfigRemove(c.daemon.db, c.id, key)
                if err != nil {
+                       AADestroy(c)
                        c.StorageStop()
                        return err
                }
@@ -1583,6 +1585,7 @@ func (c *containerLXC) OnStart() error {
 
        err = c.templateApplyNow("start")
        if err != nil {
+               AADestroy(c)
                c.StorageStop()
                return err
        }

From 8f5d0ef5e3ee447546f2991ba565225f7776c2dd Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.ander...@canonical.com>
Date: Mon, 24 Oct 2016 18:38:25 +0000
Subject: [PATCH 2/2] log OnStart/OnStop hook errors

The problem here is that liblxc doesn't log errors in hooks, it just logs
the exit code, so if a hook fails and someone isn't running in debug mode,
we really have no way to figure out what went wrong. Let's at least log the
error that the hook gave.

Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com>
---
 lxd/api_internal.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lxd/api_internal.go b/lxd/api_internal.go
index ad32446..51c11e3 100644
--- a/lxd/api_internal.go
+++ b/lxd/api_internal.go
@@ -6,6 +6,10 @@ import (
        "strconv"
 
        "github.com/gorilla/mux"
+
+       "github.com/lxc/lxd/shared"
+
+       log "gopkg.in/inconshreveable/log15.v2"
 )
 
 var apiInternal = []Command{
@@ -55,6 +59,7 @@ func internalContainerOnStart(d *Daemon, r *http.Request) 
Response {
 
        err = c.OnStart()
        if err != nil {
+               shared.Log.Error("start hook failed", log.Ctx{"container": 
c.Name(), "err": err})
                return SmartError(err)
        }
 
@@ -79,6 +84,7 @@ func internalContainerOnStop(d *Daemon, r *http.Request) 
Response {
 
        err = c.OnStop(target)
        if err != nil {
+               shared.Log.Error("stop hook failed", log.Ctx{"container": 
c.Name(), "err": err})
                return SmartError(err)
        }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to