[lxc-devel] [lxd/master] lvm: make errors log as errors

tych0 on Github lxc-bot at linuxcontainers.org
Thu Mar 10 16:42:41 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 581 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160310/35b24532/attachment.bin>
-------------- next part --------------
From b577ca63b5f984e0fe0a3dab74110951bb2af303 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at canonical.com>
Date: Thu, 10 Mar 2016 09:41:21 -0700
Subject: [PATCH] lvm: make errors log as errors

Since these are actual errors that are unexpected, let's log them as such.
Perhaps we should even go so far as to render the LVM output in the error
that's reported to the user, although I didn't do that right now.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 lxd/storage_lvm.go | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index 8d6cccd..f2caac1 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -24,7 +24,7 @@ var storageLvmDefaultThinPoolName = "LXDPool"
 func storageLVMCheckVolumeGroup(vgName string) error {
 	output, err := exec.Command("vgdisplay", "-s", vgName).CombinedOutput()
 	if err != nil {
-		shared.Log.Debug("vgdisplay failed to find vg", log.Ctx{"output": string(output)})
+		shared.Log.Error("vgdisplay failed to find vg", log.Ctx{"output": string(output)})
 		return fmt.Errorf("LVM volume group '%s' not found", vgName)
 	}
 
@@ -901,7 +901,7 @@ func (s *storageLvm) createDefaultThinPool() (string, error) {
 		fmt.Sprintf("%s/%s", s.vgName, storageLvmDefaultThinPoolName))
 
 	if err != nil {
-		s.log.Debug(
+		s.log.Error(
 			"Could not create thin pool",
 			log.Ctx{
 				"name":   storageLvmDefaultThinPoolName,
@@ -920,7 +920,7 @@ func (s *storageLvm) createDefaultThinPool() (string, error) {
 		fmt.Sprintf("%s/%s", s.vgName, storageLvmDefaultThinPoolName))
 
 	if err != nil {
-		s.log.Debug(
+		s.log.Error(
 			"Could not grow thin pool",
 			log.Ctx{
 				"name":   storageLvmDefaultThinPoolName,
@@ -965,7 +965,7 @@ func (s *storageLvm) createThinLV(lvname string) (string, error) {
 		fmt.Sprintf("%s/%s", s.vgName, poolname))
 
 	if err != nil {
-		s.log.Debug("Could not create LV", log.Ctx{"lvname": lvname, "output": string(output)})
+		s.log.Error("Could not create LV", log.Ctx{"lvname": lvname, "output": string(output)})
 		return "", fmt.Errorf("Could not create thin LV named %s", lvname)
 	}
 
@@ -1002,7 +1002,7 @@ func (s *storageLvm) removeLV(lvname string) error {
 		"lvremove", "-f", fmt.Sprintf("%s/%s", s.vgName, lvname))
 
 	if err != nil {
-		s.log.Debug("Could not remove LV", log.Ctx{"lvname": lvname, "output": string(output)})
+		s.log.Error("Could not remove LV", log.Ctx{"lvname": lvname, "output": string(output)})
 		return fmt.Errorf("Could not remove LV named %s", lvname)
 	}
 
@@ -1029,7 +1029,7 @@ func (s *storageLvm) createSnapshotLV(lvname string, origlvname string, readonly
 			"-s", fmt.Sprintf("/dev/%s/%s", s.vgName, origlvname))
 	}
 	if err != nil {
-		s.log.Debug("Could not create LV snapshot", log.Ctx{"lvname": lvname, "origlvname": origlvname, "output": string(output)})
+		s.log.Error("Could not create LV snapshot", log.Ctx{"lvname": lvname, "origlvname": origlvname, "output": string(output)})
 		return "", fmt.Errorf("Could not create snapshot LV named %s", lvname)
 	}
 


More information about the lxc-devel mailing list