From acab9b0ead162190a2a0ca9fcaed56175e7a1ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 27 Feb 2020 16:51:35 +0100 Subject: [PATCH] ceph: enable command debug when DEBUG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only print command debugs if the operator log level is DEBUG. Signed-off-by: Sébastien Han --- pkg/daemon/ceph/client/command.go | 19 +++++++++++++++++-- pkg/operator/ceph/cluster/mon/health.go | 2 +- pkg/operator/ceph/cluster/mon/mon.go | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/pkg/daemon/ceph/client/command.go b/pkg/daemon/ceph/client/command.go index 04a9ad824..42b7e4958 100644 --- a/pkg/daemon/ceph/client/command.go +++ b/pkg/daemon/ceph/client/command.go @@ -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 diff --git a/pkg/operator/ceph/cluster/mon/health.go b/pkg/operator/ceph/cluster/mon/health.go index d8078c319..5d2271584 100644 --- a/pkg/operator/ceph/cluster/mon/health.go +++ b/pkg/operator/ceph/cluster/mon/health.go @@ -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") } diff --git a/pkg/operator/ceph/cluster/mon/mon.go b/pkg/operator/ceph/cluster/mon/mon.go index c1df421bb..1bde870ea 100644 --- a/pkg/operator/ceph/cluster/mon/mon.go +++ b/pkg/operator/ceph/cluster/mon/mon.go @@ -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