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

dr: add log when dr is not configured #106

Merged
merged 1 commit into from
May 22, 2023
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
23 changes: 11 additions & 12 deletions pkg/dr/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"encoding/json"
"fmt"

log "github.com/sirupsen/logrus"

"github.com/rook/kubectl-rook-ceph/pkg/exec"
"github.com/rook/kubectl-rook-ceph/pkg/k8sutil"
"github.com/rook/kubectl-rook-ceph/pkg/logging"
rookv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -20,22 +19,23 @@ type secretData struct {
}

func Health(context *k8sutil.Context, operatorNamespace, cephClusterNamespace string, args []string) {
fmt.Println("INFO: fetching the cephblockpools with mirroring enabled")
logging.Info("fetching the cephblockpools with mirroring enabled")
blockPoolList, err := context.RookClientset.CephV1().CephBlockPools(cephClusterNamespace).List(context.Context, v1.ListOptions{})
if err != nil {
log.Error(err)
logging.Fatal(err)
}

var mirrorBlockPool rookv1.CephBlockPool
for _, blockPool := range blockPoolList.Items {
if blockPool.Spec.Mirroring.Enabled && blockPool.Spec.Mirroring.Peers != nil {
mirrorBlockPool = blockPool
fmt.Printf("found %q cephblockpool with mirroring enabled\n", mirrorBlockPool.Name)
logging.Info("found %q cephblockpool with mirroring enabled", mirrorBlockPool.Name)
}
}

if mirrorBlockPool.Name == "" {
fmt.Printf("DR is not confiqured, cephblockpool with mirroring enabled not found.\n")
logging.Warning("DR is not confiqured, cephblockpool with mirroring enabled not found.")
return
}

var secretDetail string
Expand All @@ -48,11 +48,10 @@ func Health(context *k8sutil.Context, operatorNamespace, cephClusterNamespace st

secretData, err := extractSecretData(context, operatorNamespace, cephClusterNamespace, secretDetail)
if err != nil {
fmt.Printf("failed to extract secret %s", secretDetail)
log.Fatal(err)
logging.Fatal(fmt.Errorf("failed to extract secret %s", secretDetail))
}

fmt.Println("running ceph status from peer cluster")
logging.Info("running ceph status from peer cluster")

cephArgs := []string{"-s", "--mon-host", secretData.MonHost, "--id", secretData.ClientId, "--key", secretData.Key}

Expand All @@ -64,12 +63,12 @@ func Health(context *k8sutil.Context, operatorNamespace, cephClusterNamespace st

cephStatus := exec.RunCommandInOperatorPod(context, "ceph", cephArgs, operatorNamespace, cephClusterNamespace, false)
if cephStatus == "" {
fmt.Println("failed to get ceph status from peer cluster, please check for network issues between the clusters")
logging.Warning("failed to get ceph status from peer cluster, please check for network issues between the clusters")
return
}
fmt.Println(cephStatus)
logging.Info(cephStatus)

fmt.Println("running mirroring daemon health")
logging.Info("running mirroring daemon health")

fmt.Println(exec.RunCommandInOperatorPod(context, "rbd", []string{"-p", mirrorBlockPool.Name, "mirror", "pool", "status"}, cephClusterNamespace, operatorNamespace, true))
}
Expand Down