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