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

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) ===
When the LXD API returns an error during instance creation, the actual error message is passed in data['metadata']['err'], not data['metadata']['metadata'].
Even worse metadata might be empty, in which case Nova will only show "An unknown exception occured".

This change turned "An unknown exception occured" (even with highest debug logging) into "btrfs quotas not supported. Try enabling them with 'btrfs quota enable'.".

My fix is pretty rough, because I do not understand the reasoning behind the original code. In all my tests this field was empty, while 'err' contained the error message, but you never know.

(Also, line 532: Why is data.get('metadata') used instead of regular item access? If 'metadata' is not in data, the next line will fail anyway...)
From 491e0f52854688672868ca6c8942650c11ef969d Mon Sep 17 00:00:00 2001
From: Daniel Stelter-Gliese <d...@siriuswhite.de>
Date: Wed, 25 May 2016 22:38:33 +0200
Subject: [PATCH] Show actual error message when LXD API fails

When the LXD API returns an error during instance creation, the actual error 
message is passed in data['metadata']['err'], not data['metadata']['metadata'].
Even worse metadata might be empty, in which case Nova will only show "An 
unknown exception occured".
---
 nova/virt/lxd/session.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/nova/virt/lxd/session.py b/nova/virt/lxd/session.py
index e2fdc0d..3d05e9c 100644
--- a/nova/virt/lxd/session.py
+++ b/nova/virt/lxd/session.py
@@ -531,7 +531,8 @@ def container_init(self, config, instance):
             status, data = self.operation_info(operation, instance)
             data = data.get('metadata')
             if not data['status_code'] == 200:
-                raise exception.NovaException(data['metadata'])
+                msg = data.get('err') or data['metadata']
+                raise exception.NovaException(msg)
 
             LOG.info(_LI('Successfully created container %(instance)s with'
                          ' %(image)s'), {'instance': instance.name,
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to