diff --git a/pkg/daemon/ceph/client/command.go b/pkg/daemon/ceph/client/command.go index fbb90957b79c..b8e2b74eb225 100644 --- a/pkg/daemon/ceph/client/command.go +++ b/pkg/daemon/ceph/client/command.go @@ -164,7 +164,9 @@ func (c *CephToolCommand) run() ([]byte, error) { if command == RBDTool { if c.RemoteExecution { output, stderr, err = c.context.RemoteExecutor.ExecCommandInContainerWithFullOutputWithTimeout(ProxyAppLabel, CommandProxyInitContainerName, c.clusterInfo.Namespace, append([]string{command}, args...)...) - output = fmt.Sprintf("%s. %s", output, stderr) + if stderr != "" || err != nil { + err = errors.Errorf("%s. %s", err.Error(), stderr) + } } else if c.timeout == 0 { output, err = c.context.Executor.ExecuteCommandWithOutput(command, args...) } else { diff --git a/pkg/daemon/ceph/client/command_test.go b/pkg/daemon/ceph/client/command_test.go index 6476e45053cc..d887ff46574b 100644 --- a/pkg/daemon/ceph/client/command_test.go +++ b/pkg/daemon/ceph/client/command_test.go @@ -140,7 +140,7 @@ func TestNewRBDCommand(t *testing.T) { assert.Error(t, err) assert.Len(t, cmd.args, 4) // This is not the best but it shows we go through the right codepath - assert.EqualError(t, err, "no pods found with selector \"rook-ceph-mgr\"") + assert.Contains(t, err.Error(), "no pods found with selector \"rook-ceph-mgr\"") }) t.Run("context canceled nothing to run", func(t *testing.T) {