[lxc-devel] [lxd/master] lxd/instances: Improve errors

stgraber on Github lxc-bot at linuxcontainers.org
Tue Jul 9 19:11:51 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190709/21bf40f5/attachment.bin>
-------------- next part --------------
From 34f3655829cb92c4c7e1df6fdd670ab5d72afa92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 9 Jul 2019 15:11:17 -0400
Subject: [PATCH] lxd/instances: Improve errors
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5924

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/container_instance_types.go | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lxd/container_instance_types.go b/lxd/container_instance_types.go
index b353ad5734..edc950ac32 100644
--- a/lxd/container_instance_types.go
+++ b/lxd/container_instance_types.go
@@ -233,18 +233,18 @@ func instanceParseType(value string) (map[string]string, error) {
 			fields := strings.Split(value, "-")
 			for _, field := range fields {
 				if len(field) < 2 || (field[0] != 'c' && field[0] != 'm') {
-					return nil, fmt.Errorf("Bad instance type: %s", value)
+					return nil, fmt.Errorf("Provided instance type doesn't exist: %s", value)
 				}
 
-				value, err := strconv.ParseFloat(field[1:], 32)
+				floatValue, err := strconv.ParseFloat(field[1:], 32)
 				if err != nil {
-					return nil, err
+					return nil, fmt.Errorf("Bad custom instance type: %s", value)
 				}
 
 				if field[0] == 'c' {
-					newLimits.CPU = float32(value)
+					newLimits.CPU = float32(floatValue)
 				} else if field[0] == 'm' {
-					newLimits.Memory = float32(value)
+					newLimits.Memory = float32(floatValue)
 				}
 			}
 


More information about the lxc-devel mailing list