Skip to content

Commit e00fd7d

Browse files
committed
csi: enhance error messages
this commit enhances the error messgae to give detail info to the users. Signed-off-by: yati1998 <ypadia@redhat.com>
1 parent 6d67a4d commit e00fd7d

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

pkg/filesystem/subvolume.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func checkForExternalStorage(ctx context.Context, clientsets *k8sutil.Clientsets
6262
enable := false
6363
cephclusters, err := clientsets.Rook.CephV1().CephClusters(clusterNamespace).List(ctx, v1.ListOptions{})
6464
if err != nil {
65-
logging.Fatal(fmt.Errorf("failed to list CephClusters: %q", err))
65+
logging.Fatal(fmt.Errorf("failed to list CephClusters in namespace %q: %v", clusterNamespace, err))
6666
}
6767
for i := range cephclusters.Items {
6868
enable = cephclusters.Items[i].Spec.External.Enable
@@ -80,13 +80,13 @@ func getExternalClusterDetails(ctx context.Context, clientsets *k8sutil.Clientse
8080

8181
scList, err := clientsets.Kube.CoreV1().Secrets(clusterNamespace).List(ctx, v1.ListOptions{})
8282
if err != nil {
83-
logging.Fatal(fmt.Errorf("Error fetching secrets: %v\n", err))
83+
logging.Fatal(fmt.Errorf("Error fetching secrets in namespace %q: %v", clusterNamespace, err))
8484
}
8585
for i := range scList.Items {
8686
if strings.HasPrefix(scList.Items[i].ObjectMeta.Name, "rook-csi-cephfs-provisioner") {
8787
data := scList.Items[i].Data
8888
if data == nil {
89-
logging.Fatal(fmt.Errorf("Secret data is empty"))
89+
logging.Fatal(fmt.Errorf("Secret data is empty for %s/%s", clusterNamespace, scList.Items[i].ObjectMeta.Name))
9090
}
9191
adminId = string(data["adminID"])
9292
adminKey = string(data["adminKey"])
@@ -97,18 +97,18 @@ func getExternalClusterDetails(ctx context.Context, clientsets *k8sutil.Clientse
9797

9898
cm, err := clientsets.Kube.CoreV1().ConfigMaps(clusterNamespace).Get(ctx, "rook-ceph-mon-endpoints", v1.GetOptions{})
9999
if err != nil {
100-
logging.Fatal(fmt.Errorf("Error fetching configmaps: %v\n", err))
100+
logging.Fatal(fmt.Errorf("Error fetching configmaps %s/rook-ceph-mon-endpoints: %v", clusterNamespace, err))
101101
}
102102

103103
if len(cm.Data) == 0 || cm.Data == nil {
104-
logging.Fatal(fmt.Errorf("Configmap data is empty"))
104+
logging.Fatal(fmt.Errorf("Configmap data is empty for %s/rook-ceph-mon-endpoints", clusterNamespace))
105105
}
106106
monpoint := cm.Data["csi-cluster-config-json"]
107107
var monip []monitor
108108
json.Unmarshal([]byte(monpoint), &monip)
109109
for _, mp := range monip {
110110
if len(mp.Monitors) == 0 || mp.Monitors[0] == "" {
111-
logging.Fatal(fmt.Errorf("mon ip is empty"))
111+
logging.Fatal(fmt.Errorf("mon ip for %s/rook-ceph-mon-endpoints with clusterID:%q is empty", clusterNamespace, mp.ClusterID))
112112
}
113113
m = mp.Monitors[0]
114114
}

0 commit comments

Comments
 (0)