[lxc-devel] [lxd/master] lxd/storage/ceph: Don't mix stderr with json

stgraber on Github lxc-bot at linuxcontainers.org
Thu Apr 11 21:30:34 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/20190411/294fe937/attachment.bin>
-------------- next part --------------
From 97d98151a7e1322c177bb4bd17c67b7492779746 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 11 Apr 2019 17:10:28 -0400
Subject: [PATCH] lxd/storage/ceph: Don't mix stderr with json
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5651

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

diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index 313c1f4c66..1966b9f9bd 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -1,6 +1,7 @@
 package main
 
 import (
+	"bytes"
 	"encoding/json"
 	"fmt"
 	"io"
@@ -2524,7 +2525,8 @@ func (s *storageCeph) StorageEntitySetQuota(volumeType int, size int64, data int
 }
 
 func (s *storageCeph) StoragePoolResources() (*api.ResourcesStoragePool, error) {
-	buf, err := shared.RunCommand(
+	var stdout bytes.Buffer
+	err := shared.RunCommandWithFds(nil, &stdout,
 		"ceph",
 		"--name", fmt.Sprintf("client.%s", s.UserName),
 		"--cluster", s.ClusterName,
@@ -2551,7 +2553,7 @@ func (s *storageCeph) StoragePoolResources() (*api.ResourcesStoragePool, error)
 
 	// Parse the JSON output
 	df := cephDf{}
-	err = json.Unmarshal([]byte(buf), &df)
+	err = json.Unmarshal(stdout.Bytes(), &df)
 	if err != nil {
 		return nil, err
 	}


More information about the lxc-devel mailing list