Skip to content

Commit

Permalink
pool: include error output in ceph command results
Browse files Browse the repository at this point in the history
The ceph command prints errors to stderr and is being ignored
by failures in most of the pool commands, which makes
troubleshooting difficult when there is a failure. Include the
output now for all the pool commands in case of failure.

Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
  • Loading branch information
travisn committed Apr 11, 2024
1 parent 593964c commit 68928ea
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions pkg/daemon/ceph/client/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,16 @@ func DeletePool(context *clusterd.Context, clusterInfo *ClusterInfo, name string

logger.Infof("purging pool %q (id=%d)", name, pool.Number)
args := []string{"osd", "pool", "delete", name, name, reallyConfirmFlag}
_, err = NewCephCommand(context, clusterInfo, args).Run()
output, err := NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to delete pool %q", name)
return errors.Wrapf(err, "failed to delete pool %q. %s", name, string(output))
}

// remove the crush rule for this pool and ignore the error in case the rule is still in use or not found
args = []string{"osd", "crush", "rule", "rm", name}
_, err = NewCephCommand(context, clusterInfo, args).Run()
output, err = NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
logger.Errorf("failed to delete crush rule %q. %v", name, err)
logger.Errorf("failed to delete crush rule %q. %v. %s", name, err, string(output))
}

logger.Infof("purge completed for pool %q", name)
Expand All @@ -280,9 +280,9 @@ func givePoolAppTag(context *clusterd.Context, clusterInfo *ClusterInfo, poolNam
}

args := []string{"osd", "pool", "application", "enable", poolName, appName, confirmFlag}
_, err = NewCephCommand(context, clusterInfo, args).Run()
output, err := NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to enable application %q on pool %q", appName, poolName)
return errors.Wrapf(err, "failed to enable application %q on pool %q. %s", appName, poolName, string(output))
}

return nil
Expand Down Expand Up @@ -543,9 +543,9 @@ func extractPoolDetails(rule ruleSpec) (string, string) {
func setCrushRule(context *clusterd.Context, clusterInfo *ClusterInfo, poolName, crushRule string) error {
args := []string{"osd", "pool", "set", poolName, "crush_rule", crushRule}

_, err := NewCephCommand(context, clusterInfo, args).Run()
output, err := NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to set crush rule %q", crushRule)
return errors.Wrapf(err, "failed to set crush rule %q. %s", crushRule, string(output))
}
return nil
}
Expand Down Expand Up @@ -708,9 +708,9 @@ func createReplicationCrushRule(context *clusterd.Context, clusterInfo *ClusterI
func SetPoolProperty(context *clusterd.Context, clusterInfo *ClusterInfo, name, propName, propVal string) error {
args := []string{"osd", "pool", "set", name, propName, propVal}
logger.Infof("setting pool property %q to %q on pool %q", propName, propVal, name)
_, err := NewCephCommand(context, clusterInfo, args).Run()
output, err := NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to set pool property %q on pool %q", propName, name)
return errors.Wrapf(err, "failed to set pool property %q on pool %q. %s", propName, name, string(output))
}
return nil
}
Expand All @@ -719,9 +719,9 @@ func SetPoolProperty(context *clusterd.Context, clusterInfo *ClusterInfo, name,
func setPoolQuota(context *clusterd.Context, clusterInfo *ClusterInfo, poolName, quotaType, quotaVal string) error {
args := []string{"osd", "pool", "set-quota", poolName, quotaType, quotaVal}
logger.Infof("setting quota %q=%q on pool %q", quotaType, quotaVal, poolName)
_, err := NewCephCommand(context, clusterInfo, args).Run()
output, err := NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to set %q quota on pool %q", quotaType, poolName)
return errors.Wrapf(err, "failed to set %q quota on pool %q. %s", quotaType, poolName, string(output))
}
return nil
}
Expand All @@ -734,9 +734,9 @@ func SetPoolReplicatedSizeProperty(context *clusterd.Context, clusterInfo *Clust
args = append(args, "--yes-i-really-mean-it")
}

_, err := NewCephCommand(context, clusterInfo, args).Run()
output, err := NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to set pool property %q on pool %q", propName, poolName)
return errors.Wrapf(err, "failed to set pool property %q on pool %q. %s", propName, poolName, string(output))
}

return nil
Expand Down

0 comments on commit 68928ea

Please sign in to comment.