From 704786f27372641b6f51da4402224dd30768d76b Mon Sep 17 00:00:00 2001 From: Blaine Gardner Date: Mon, 9 Sep 2019 09:23:56 -0600 Subject: [PATCH] Ceph: use combined output from ceph-volume ceph-volume now sends status and log output to stderr, which breaks `ceph-volume lvm prepare` if not other things as well. Use the combined stdout and stderr output from ceph-volume to fix this. Signed-off-by: Blaine Gardner --- pkg/daemon/ceph/osd/agent_test.go | 6 +++++- pkg/daemon/ceph/osd/volume.go | 8 ++++---- pkg/daemon/ceph/osd/volume_test.go | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/daemon/ceph/osd/agent_test.go b/pkg/daemon/ceph/osd/agent_test.go index 77d8c1834..25665c267 100644 --- a/pkg/daemon/ceph/osd/agent_test.go +++ b/pkg/daemon/ceph/osd/agent_test.go @@ -217,6 +217,10 @@ func testOSDAgentWithDevicesHelper(t *testing.T, storeConfig config.StoreConfig, assert.Equal(t, config.Bluestore, storeConfig.StoreType) return `SIZE="1234567890" TYPE="part"`, nil } + return "", nil + } + executor.MockExecuteCommandWithCombinedOutput = func(debug bool, actionName string, command string, args ...string) (string, error) { + outputExecCount++ if command == "ceph-volume" { if args[1] == "list" { return `{}`, nil @@ -386,7 +390,7 @@ func createTestAgent(t *testing.T, devices, configDir, nodeName string, storeCon logger.Infof("%s %v", command, args) return "{\"key\":\"mysecurekey\", \"osdid\":3.0}", nil }, - MockExecuteCommandWithOutput: func(debug bool, actionName string, command string, args ...string) (string, error) { + MockExecuteCommandWithCombinedOutput: func(debug bool, actionName string, command string, args ...string) (string, error) { logger.Infof("%s %v", command, args) if command == "ceph-volume" { if len(args) == 3 && args[0] == "lvm" && args[1] == "batch" && args[2] == "--prepare" { diff --git a/pkg/daemon/ceph/osd/volume.go b/pkg/daemon/ceph/osd/volume.go index 5d4e28842..808a8e6de 100644 --- a/pkg/daemon/ceph/osd/volume.go +++ b/pkg/daemon/ceph/osd/volume.go @@ -101,7 +101,7 @@ func (a *OsdAgent) initializeBlockPVC(context *clusterd.Context, devices *Device }...) // execute ceph-volume with the device - if op, err := context.Executor.ExecuteCommandWithOutput(false, "", baseCommand, immediateExecuteArgs...); err != nil { + if op, err := context.Executor.ExecuteCommandWithCombinedOutput(false, "", baseCommand, immediateExecuteArgs...); err != nil { return "", fmt.Errorf("failed ceph-volume. %+v", err) // fail return here as validation provided by ceph-volume } else { logger.Infof("%v", op) @@ -309,7 +309,7 @@ func (a *OsdAgent) initializeDevices(context *clusterd.Context, devices *DeviceO "json", }...) - cvOut, err := context.Executor.ExecuteCommandWithOutput(false, "", baseCommand, reportArgs...) + cvOut, err := context.Executor.ExecuteCommandWithCombinedOutput(false, "", baseCommand, reportArgs...) if err != nil { return fmt.Errorf("failed ceph-volume json report. %+v", err) // fail return here as validation provided by ceph-volume } @@ -350,7 +350,7 @@ func sanitizeOSDsPerDevice(count int) string { func getCephVolumeSupported(context *clusterd.Context) (bool, error) { - _, err := context.Executor.ExecuteCommandWithOutput(false, "", cephVolumeCmd, "lvm", "batch", "--prepare") + _, err := context.Executor.ExecuteCommandWithCombinedOutput(false, "", cephVolumeCmd, "lvm", "batch", "--prepare") if err != nil { if cmdErr, ok := err.(*exec.CommandError); ok { @@ -369,7 +369,7 @@ func getCephVolumeSupported(context *clusterd.Context) (bool, error) { func getCephVolumeOSDs(context *clusterd.Context, clusterName string, cephfsid string, lv string) ([]oposd.OSDInfo, error) { - result, err := context.Executor.ExecuteCommandWithOutput(false, "", cephVolumeCmd, "lvm", "list", lv, "--format", "json") + result, err := context.Executor.ExecuteCommandWithCombinedOutput(false, "", cephVolumeCmd, "lvm", "list", lv, "--format", "json") if err != nil { return nil, fmt.Errorf("failed to retrieve ceph-volume results. %+v", err) } diff --git a/pkg/daemon/ceph/osd/volume_test.go b/pkg/daemon/ceph/osd/volume_test.go index ac08a2041..6b1d67a08 100644 --- a/pkg/daemon/ceph/osd/volume_test.go +++ b/pkg/daemon/ceph/osd/volume_test.go @@ -241,7 +241,7 @@ var cephVolumeTestResultMultiClusterMultiOSD = `{ func TestParseCephVolumeResult(t *testing.T) { executor := &exectest.MockExecutor{} // set up a mock function to return "rook owned" partitions on the device and it does not have a filesystem - executor.MockExecuteCommandWithOutput = func(debug bool, name string, command string, args ...string) (string, error) { + executor.MockExecuteCommandWithCombinedOutput = func(debug bool, name string, command string, args ...string) (string, error) { logger.Infof("%s %+v", command, args) if command == "ceph-volume" { @@ -261,7 +261,7 @@ func TestParseCephVolumeResult(t *testing.T) { func TestCephVolumeResultMultiClusterSingleOSD(t *testing.T) { executor := &exectest.MockExecutor{} // set up a mock function to return "rook owned" partitions on the device and it does not have a filesystem - executor.MockExecuteCommandWithOutput = func(debug bool, name string, command string, args ...string) (string, error) { + executor.MockExecuteCommandWithCombinedOutput = func(debug bool, name string, command string, args ...string) (string, error) { logger.Infof("%s %+v", command, args) if command == "ceph-volume" { @@ -282,7 +282,7 @@ func TestCephVolumeResultMultiClusterSingleOSD(t *testing.T) { func TestCephVolumeResultMultiClusterMultiOSD(t *testing.T) { executor := &exectest.MockExecutor{} // set up a mock function to return "rook owned" partitions on the device and it does not have a filesystem - executor.MockExecuteCommandWithOutput = func(debug bool, name string, command string, args ...string) (string, error) { + executor.MockExecuteCommandWithCombinedOutput = func(debug bool, name string, command string, args ...string) (string, error) { logger.Infof("%s %+v", command, args) if command == "ceph-volume" {