Skip to content

Commit b02d972

Browse files
committed
Enhancing logging and errors
1 parent e135cfb commit b02d972

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

commons/database/utils.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -594,24 +594,25 @@ func GetSidPdbEdition(r client.Reader, config *rest.Config, ctx context.Context,
594594

595595
log := ctrllog.FromContext(ctx).WithValues("GetSidbPdbEdition", req.NamespacedName)
596596

597-
sidbReadyPod, _, _, _, err := FindPods(r, "", "", req.Name, req.Namespace, ctx, req)
597+
readyPod, _, _, _, err := FindPods(r, "", "", req.Name, req.Namespace, ctx, req)
598598
if err != nil {
599599
log.Error(err, err.Error())
600-
return "", "", "", errors.New("error while fetching sidb ready pod for sidb " + req.Name)
600+
return "", "", "", fmt.Errorf("error while fetching ready pod %s : \n %s", readyPod.Name, err.Error())
601601
}
602-
if sidbReadyPod.Name != "" {
603-
out, err := ExecCommand(r, config, sidbReadyPod.Name, sidbReadyPod.Namespace, "",
602+
if readyPod.Name != "" {
603+
out, err := ExecCommand(r, config, readyPod.Name, readyPod.Namespace, "",
604604
ctx, req, false, "bash", "-c", GetSidPdbEditionCMD)
605605
if err != nil {
606606
log.Error(err, err.Error())
607-
return "", "", "", errors.New("error while execing GetSidPdbEditionCMD on sidb " + req.Name)
607+
return "", "", "", err
608608
}
609609
log.Info(out)
610610
splitstr := strings.Split(strings.TrimSpace(out), ",")
611611
return splitstr[0], splitstr[1], splitstr[2], nil
612612
}
613-
614-
return "", "", "", errors.New("error while sidb ready pod name is nil")
613+
err = errors.New("ready pod name is nil")
614+
log.Error(err, err.Error())
615+
return "", "", "", err
615616
}
616617

617618
// Get Datapatch Status

0 commit comments

Comments
 (0)