Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use logger to obtain commands stderr instead of directly passing STDERR #52

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions ceph/ceph.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
"os"
"os/exec"

"github.com/pkg/errors"
Expand Down Expand Up @@ -37,7 +36,7 @@ func (c *ceph) ApplyCephConfigOption(ctx context.Context, section, key, value st
bin, args := mkCommand(c.binaryPath, []string{"config", "set", section, key, value})

cmd := exec.CommandContext(ctx, bin, args...)
cmd.Stderr = os.Stderr
cmd.Stderr = log.StandardLogger().WriterLevel(log.DebugLevel)
if err := cmd.Run(); err != nil {
return errors.Wrap(err, "error applying configuration")
}
Expand All @@ -50,7 +49,7 @@ func (c *ceph) ClusterReport(ctx context.Context) (models.ClusterReport, error)

cmd := exec.CommandContext(ctx, bin, args...)
cmd.Stdout = buf
cmd.Stderr = os.Stderr
cmd.Stderr = log.StandardLogger().WriterLevel(log.DebugLevel)
if err := cmd.Run(); err != nil {
return models.ClusterReport{}, errors.Wrap(err, "error retrieving report")
}
Expand All @@ -71,7 +70,7 @@ func (c ceph) ClusterStatus(ctx context.Context) (models.ClusterStatus, error) {

cmd := exec.CommandContext(ctx, bin, args...)
cmd.Stdout = buf
cmd.Stderr = os.Stderr
cmd.Stderr = log.StandardLogger().WriterLevel(log.DebugLevel)
if err := cmd.Run(); err != nil {
return models.ClusterStatus{}, errors.Wrap(err, "error retrieving cluster status")
}
Expand All @@ -93,7 +92,7 @@ func (c *ceph) DumpConfig(ctx context.Context) (models.CephConfig, error) {

cmd := exec.CommandContext(ctx, bin, args...)
cmd.Stdout = buf
cmd.Stderr = os.Stderr
cmd.Stderr = log.StandardLogger().WriterLevel(log.DebugLevel)
if err := cmd.Run(); err != nil {
return nil, errors.Wrap(err, "error running command")
}
Expand Down Expand Up @@ -122,7 +121,7 @@ func (c *ceph) ListDevices(ctx context.Context) ([]models.Device, error) {

cmd := exec.CommandContext(ctx, bin, args...)
cmd.Stdout = buf
cmd.Stderr = os.Stderr
cmd.Stderr = log.StandardLogger().WriterLevel(log.DebugLevel)
if err := cmd.Run(); err != nil {
return nil, errors.Wrap(err, "error listing devices")
}
Expand All @@ -147,7 +146,7 @@ func (c *ceph) RemoveCephConfigOption(ctx context.Context, section, key string)
bin, args := mkCommand(c.binaryPath, []string{"config", "rm", section, key})

cmd := exec.CommandContext(ctx, bin, args...)
cmd.Stderr = os.Stderr
cmd.Stderr = log.StandardLogger().WriterLevel(log.DebugLevel)
if err := cmd.Run(); err != nil {
return errors.Wrap(err, "error applying configuration")
}
Expand Down
Loading