d84cf8
From 9cbab9110523cfafe23d6c6b3080d0d744062b85 Mon Sep 17 00:00:00 2001
d84cf8
From: Mohammed Rafi KC <rkavunga@redhat.com>
d84cf8
Date: Thu, 21 May 2020 16:04:33 +0530
d84cf8
Subject: [PATCH 440/449] glusterd/snapshot: Improve log message during
d84cf8
 snapshot clone
d84cf8
d84cf8
While taking a snapshot clone, if the snapshot is not activated,
d84cf8
the cli was returning that the bricks are down.
d84cf8
This patch clearly print tha the error is due to the snapshot
d84cf8
state.
d84cf8
d84cf8
>Change-Id: Ia840e6e071342e061ad38bf15e2e2ff2b0dacdfa
d84cf8
>Fixes: #1255
d84cf8
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
d84cf8
Upstream Patch: https://review.gluster.org/#/c/glusterfs/+/24478/
d84cf8
d84cf8
BUG: 1837926
d84cf8
Change-Id: Ia840e6e071342e061ad38bf15e2e2ff2b0dacdfa
d84cf8
Signed-off-by: Srijan Sivakumar <ssivakum@redhat.com>
d84cf8
Reviewed-on: https://code.engineering.redhat.com/gerrit/202707
d84cf8
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d84cf8
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d84cf8
---
d84cf8
 xlators/mgmt/glusterd/src/glusterd-snapshot.c | 15 ++++++++++++---
d84cf8
 1 file changed, 12 insertions(+), 3 deletions(-)
d84cf8
d84cf8
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
d84cf8
index c56be91..5b8ae97 100644
d84cf8
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
d84cf8
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
d84cf8
@@ -2238,7 +2238,6 @@ glusterd_snapshot_clone_prevalidate(dict_t *dict, char **op_errstr,
d84cf8
     char *clonename = NULL;
d84cf8
     char *snapname = NULL;
d84cf8
     char device_name[64] = "";
d84cf8
-    char key[PATH_MAX] = "";
d84cf8
     glusterd_snap_t *snap = NULL;
d84cf8
     char err_str[PATH_MAX] = "";
d84cf8
     int ret = -1;
d84cf8
@@ -2299,8 +2298,18 @@ glusterd_snapshot_clone_prevalidate(dict_t *dict, char **op_errstr,
d84cf8
         goto out;
d84cf8
     }
d84cf8
 
d84cf8
-    snprintf(key, sizeof(key) - 1, "vol1_volid");
d84cf8
-    ret = dict_get_bin(dict, key, (void **)&snap_volid);
d84cf8
+
d84cf8
+    if (!glusterd_is_volume_started(snap_vol)) {
d84cf8
+        snprintf(err_str, sizeof(err_str),
d84cf8
+                 "Snapshot %s is "
d84cf8
+                 "not activated",
d84cf8
+                 snap->snapname);
d84cf8
+        loglevel = GF_LOG_WARNING;
d84cf8
+        *op_errno = EG_VOLSTP;
d84cf8
+        goto out;
d84cf8
+    }
d84cf8
+
d84cf8
+    ret = dict_get_bin(dict, "vol1_volid", (void **)&snap_volid);
d84cf8
     if (ret) {
d84cf8
         gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
d84cf8
                "Unable to fetch snap_volid");
d84cf8
-- 
d84cf8
1.8.3.1
d84cf8