ceph: enable command debug when DEBUG
Only print command debugs if the operator log level is DEBUG. Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
1 parent
9f13cba8be
commit
acab9b0ead
3 files changed
+19
-4
No files matched your search
@@ -18,6 +18,7 @@ package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
@@ -107,12 +108,26 @@ func newCephToolCommand(tool string, context *clusterd.Context, clusterName stri
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: make this work even if the operator config comes from the CM?
|
||||
// IsDebugLevel detects operator log level
|
||||
func IsDebugLevel() bool {
|
||||
logLevel := os.Getenv("ROOK_LOG_LEVEL")
|
||||
switch logLevel {
|
||||
case "INFO":
|
||||
return true
|
||||
case "DEBUG":
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func NewCephCommand(context *clusterd.Context, clusterName string, args []string) *CephToolCommand {
|
||||
return newCephToolCommand(CephTool, context, clusterName, args, false)
|
||||
return newCephToolCommand(CephTool, context, clusterName, args, IsDebugLevel())
|
||||
}
|
||||
|
||||
func NewRBDCommand(context *clusterd.Context, clusterName string, args []string) *CephToolCommand {
|
||||
cmd := newCephToolCommand(RBDTool, context, clusterName, args, false)
|
||||
cmd := newCephToolCommand(RBDTool, context, clusterName, args, IsDebugLevel())
|
||||
cmd.JsonOutput = false
|
||||
cmd.OutputFile = false
|
||||
return cmd
|
||||
|
||||
@@ -83,7 +83,7 @@ func (c *Cluster) checkHealth() error {
|
||||
|
||||
// connect to the mons
|
||||
// get the status and check for quorum
|
||||
quorumStatus, err := client.GetMonQuorumStatus(c.context, c.ClusterInfo.Name, true)
|
||||
quorumStatus, err := client.GetMonQuorumStatus(c.context, c.ClusterInfo.Name, client.IsDebugLevel())
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get mon quorum status")
|
||||
}
|
||||
|
||||
@@ -986,7 +986,7 @@ func waitForQuorumWithMons(context *clusterd.Context, clusterName string, mons [
|
||||
|
||||
// get the quorum_status response that contains info about all monitors in the mon map and
|
||||
// their quorum status
|
||||
monQuorumStatusResp, err := client.GetMonQuorumStatus(context, clusterName, false)
|
||||
monQuorumStatusResp, err := client.GetMonQuorumStatus(context, clusterName, client.IsDebugLevel())
|
||||
if err != nil {
|
||||
logger.Debugf("failed to get quorum_status. %v", err)
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user