Skip to content

Commit

Permalink
core: add the ability to execute ceph commands with a combined output
Browse files Browse the repository at this point in the history
Sometimes Ceph uses a different standard output to return errors or
merges standard error to standard out. So let's allow some commands to
return both in the output.

Signed-off-by: Sébastien Han <seb@redhat.com>
  • Loading branch information
leseb committed Nov 26, 2021
1 parent d1cdba4 commit 7f7a72d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/daemon/ceph/client/command.go
Expand Up @@ -96,16 +96,18 @@ type CephToolCommand struct {
args []string
timeout time.Duration
JsonOutput bool
combinedOutput bool
RemoteExecution bool
}

func newCephToolCommand(tool string, context *clusterd.Context, clusterInfo *ClusterInfo, args []string) *CephToolCommand {
return &CephToolCommand{
context: context,
tool: tool,
clusterInfo: clusterInfo,
args: args,
JsonOutput: true,
context: context,
tool: tool,
clusterInfo: clusterInfo,
args: args,
JsonOutput: true,
combinedOutput: false,
}
}

Expand Down Expand Up @@ -173,7 +175,11 @@ func (c *CephToolCommand) run() ([]byte, error) {
output, err = c.context.Executor.ExecuteCommandWithTimeout(c.timeout, command, args...)
}
} else if c.timeout == 0 {
output, err = c.context.Executor.ExecuteCommandWithOutput(command, args...)
if c.combinedOutput {
output, err = c.context.Executor.ExecuteCommandWithCombinedOutput(command, args...)
} else {
output, err = c.context.Executor.ExecuteCommandWithOutput(command, args...)
}
} else {
output, err = c.context.Executor.ExecuteCommandWithTimeout(c.timeout, command, args...)
}
Expand Down

0 comments on commit 7f7a72d

Please sign in to comment.