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

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) ===
lxd: Updates error handling of MakeFSType after stderr split of RunCommand.

- Adds stdout output in brackets after error.
- Makes lvmCreateLv error output consistent with other uses of MakeFSType.

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
From 2ade14b1569d9bec2b8203d8c88641cececd3d49 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Mon, 7 Oct 2019 13:02:51 +0100
Subject: [PATCH] lxd: Updates error handling of MakeFSType after stderr split
 of RunCommand

- Adds stdout output in brackets after error.
- Makes lvmCreateLv error output consistent with other uses of MakeFSType.

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/storage_btrfs.go      | 4 ++--
 lxd/storage_ceph.go       | 9 ++++-----
 lxd/storage_ceph_utils.go | 4 ++--
 lxd/storage_lvm_utils.go  | 4 ++--
 4 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index 3220b10af2..73926948fc 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -160,7 +160,7 @@ func (s *storageBtrfs) StoragePoolCreate() error {
 
                output, err := driver.MakeFSType(source, "btrfs", 
&driver.MkfsOptions{Label: s.pool.Name})
                if err != nil {
-                       return fmt.Errorf("Failed to create the BTRFS pool: 
%s", output)
+                       return fmt.Errorf("Failed to create the BTRFS pool: %v 
(%s)", err, output)
                }
        } else {
                // Unset size property since it doesn't make sense.
@@ -171,7 +171,7 @@ func (s *storageBtrfs) StoragePoolCreate() error {
                        if isBlockDev {
                                output, err := driver.MakeFSType(source, 
"btrfs", &driver.MkfsOptions{Label: s.pool.Name})
                                if err != nil {
-                                       return fmt.Errorf("Failed to create the 
BTRFS pool: %s", output)
+                                       return fmt.Errorf("Failed to create the 
BTRFS pool: %v (%s)", err, output)
                                }
                        } else {
                                if isBtrfsSubVolume(source) {
diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index bede743bd3..708b73d3c6 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -362,9 +362,9 @@ func (s *storageCeph) StoragePoolVolumeCreate() error {
        RBDFilesystem := s.getRBDFilesystem()
        logger.Debugf(`Retrieved filesystem type "%s" of RBD storage volume 
"%s" on storage pool "%s"`, RBDFilesystem, s.volume.Name, s.pool.Name)
 
-       msg, err := driver.MakeFSType(RBDDevPath, RBDFilesystem, nil)
+       output, err := driver.MakeFSType(RBDDevPath, RBDFilesystem, nil)
        if err != nil {
-               logger.Errorf(`Failed to create filesystem type "%s" on device 
path "%s" for RBD storage volume "%s" on storage pool "%s": %s`, RBDFilesystem, 
RBDDevPath, s.volume.Name, s.pool.Name, msg)
+               logger.Errorf(`Failed to create filesystem type "%s" on device 
path "%s" for RBD storage volume "%s" on storage pool "%s": %v (%s)`, 
RBDFilesystem, RBDDevPath, s.volume.Name, s.pool.Name, err, output)
                return err
        }
        logger.Debugf(`Created filesystem type "%s" on device path "%s" for RBD 
storage volume "%s" on storage pool "%s"`, RBDFilesystem, RBDDevPath, 
s.volume.Name, s.pool.Name)
@@ -2106,10 +2106,9 @@ func (s *storageCeph) ImageCreate(fingerprint string, 
tracker *ioprogress.Progre
 
                // get filesystem
                RBDFilesystem := s.getRBDFilesystem()
-               msg, err := driver.MakeFSType(RBDDevPath, RBDFilesystem, nil)
+               output, err := driver.MakeFSType(RBDDevPath, RBDFilesystem, nil)
                if err != nil {
-                       logger.Errorf(`Failed to create filesystem "%s" for RBD 
storage volume for image "%s" on storage pool "%s": %s`, RBDFilesystem, 
fingerprint,
-                               s.pool.Name, msg)
+                       logger.Errorf(`Failed to create filesystem "%s" for RBD 
storage volume for image "%s" on storage pool "%s": %v (%s)`, RBDFilesystem, 
fingerprint, s.pool.Name, err, output)
                        return err
                }
                logger.Debugf(`Created filesystem "%s" for RBD storage volume 
for image "%s" on storage pool "%s"`, RBDFilesystem, fingerprint, s.pool.Name)
diff --git a/lxd/storage_ceph_utils.go b/lxd/storage_ceph_utils.go
index 4d5c20222e..a23ed4352a 100644
--- a/lxd/storage_ceph_utils.go
+++ b/lxd/storage_ceph_utils.go
@@ -1752,9 +1752,9 @@ func (s *storageCeph) doContainerCreate(projectName, name 
string, privileged boo
 
        // get filesystem
        RBDFilesystem := s.getRBDFilesystem()
-       msg, err := driver.MakeFSType(RBDDevPath, RBDFilesystem, nil)
+       output, err := driver.MakeFSType(RBDDevPath, RBDFilesystem, nil)
        if err != nil {
-               logger.Errorf(`Failed to create filesystem type "%s" on device 
path "%s" for RBD storage volume for container "%s" on storage pool "%s": %s`, 
RBDFilesystem, RBDDevPath, name, s.pool.Name, msg)
+               logger.Errorf(`Failed to create filesystem type "%s" on device 
path "%s" for RBD storage volume for container "%s" on storage pool "%s": %v 
(%s)`, RBDFilesystem, RBDDevPath, name, s.pool.Name, err, output)
                return err
        }
        logger.Debugf(`Created filesystem type "%s" on device path "%s" for RBD 
storage volume for container "%s" on storage pool "%s"`, RBDFilesystem, 
RBDDevPath, name, s.pool.Name)
diff --git a/lxd/storage_lvm_utils.go b/lxd/storage_lvm_utils.go
index c73f1897cb..a504886614 100644
--- a/lxd/storage_lvm_utils.go
+++ b/lxd/storage_lvm_utils.go
@@ -856,8 +856,8 @@ func lvmCreateLv(projectName, vgName string, thinPoolName 
string, lvName string,
 
        output, err = driver.MakeFSType(fsPath, lvFsType, nil)
        if err != nil {
-               logger.Errorf("Filesystem creation failed: %s: %v", output, err)
-               return fmt.Errorf("Error making filesystem on image LV: %s: 
%v", output, err)
+               logger.Errorf("Filesystem creation failed: %v (%s)", err, 
output)
+               return fmt.Errorf("Error making filesystem on image LV: %v 
(%s)", err, output)
        }
 
        return nil
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to