summaryrefslogtreecommitdiffstats
path: root/rpc/block_svc_routines.c
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-02-20 16:09:15 +0530
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-02-20 16:30:14 +0530
commit1c5a7f4dc33bbb1738b66dd73aa281c78aa0c326 (patch)
tree98674b73131e4a740e4722cbdad77756813971fe /rpc/block_svc_routines.c
parent8515ad3db4eacae348921fd7e7599361b5b6b8e2 (diff)
gluster-blockd: treat delete success if block doesn't exist
problem: say because of some reasons create failed to config on node, so it will log CONFIGFAIL in the metafile. At the time of delete since config failed it is obvious that block will not exist. since delete cannot find it now it fails to delete hence returning -1. solution: treat delete success if there is no block with given name on that node. Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Diffstat (limited to 'rpc/block_svc_routines.c')
-rw-r--r--rpc/block_svc_routines.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c
index f755ee9..175372a 100644
--- a/rpc/block_svc_routines.c
+++ b/rpc/block_svc_routines.c
@@ -25,6 +25,7 @@
# define GB_TGCLI_GLFS_PATH "/backstores/user:glfs"
# define GB_TGCLI_GLFS "targetcli " GB_TGCLI_GLFS_PATH
+# define GB_TGCLI_CHECK GB_TGCLI_GLFS " ls | grep ' %s ' > " DEVNULLPATH
# define GB_TGCLI_ISCSI "targetcli /iscsi"
# define GB_TGCLI_GLOBALS "targetcli set global auto_add_default_portal=false > " DEVNULLPATH
# define GB_TGCLI_SAVE "targetcli / saveconfig > " DEVNULLPATH
@@ -919,6 +920,20 @@ block_delete_1_svc(blockDelete *blk, struct svc_req *rqstp)
}
reply->exit = -1;
+ if (asprintf(&exec, GB_TGCLI_CHECK, blk->block_name) == -1) {
+ goto out;
+ }
+
+ /* Check if block exist on this node ? */
+ if (WEXITSTATUS(system(exec))== 1) {
+ reply->exit = 0;
+ if (asprintf(&reply->out, "No %s.", blk->block_name) == -1) {
+ goto out;
+ }
+ goto out;
+ }
+ GB_FREE(exec);
+
if (asprintf(&iqn, "%s %s %s%s", GB_TGCLI_ISCSI, GB_DELETE,
GB_TGCLI_IQN_PREFIX, blk->gbid) == -1) {
goto out;