3604df
From a5ff2e613a5d0b2c2bf126ed16f3e36b0351c770 Mon Sep 17 00:00:00 2001
3604df
From: Aravinda VK <avishwan@redhat.com>
3604df
Date: Wed, 10 Aug 2016 14:02:09 +0530
3604df
Subject: [PATCH 198/206] geo-rep: Handle EISDIR error during Unlink
3604df
3604df
During Rename, If Source and Target has same inode then
3604df
Geo-rep unlinks source. But if source is a directory then
3604df
this will fail with below traceback
3604df
3604df
Traceback (most recent call last):
3604df
  File "/usr/libexec/glusterfs/python/syncdaemon/repce.py", line 113, in worker
3604df
    res = getattr(self.obj, rmeth)(*in_data[2:])
3604df
  File "/usr/libexec/glusterfs/python/syncdaemon/resource.py", line 772,
3604df
    in entry_ops
3604df
    os.unlink(entry)
3604df
OSError: [Errno 21] Is a directory: '.gfid/12711ebf-7fdc-4f4b-9850-2d75581eb
3604df
   452/New folder'
3604df
3604df
With this patch, if EISDIR, rmdir is tried. Logs error in Slave log in case
3604df
of ENOTEMPTY.
3604df
3604df
> Reviewed-on: http://review.gluster.org/15132
3604df
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
> Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
> Reviewed-by: Kotresh HR <khiremat@redhat.com>
3604df
3604df
BUG: 1385589
3604df
Change-Id: I099af4192adac5125c0a23988ceb6506f91e987f
3604df
Signed-off-by: Aravinda VK <avishwan@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/91362
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 geo-replication/syncdaemon/resource.py | 18 +++++++++++++++++-
3604df
 1 file changed, 17 insertions(+), 1 deletion(-)
3604df
3604df
diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py
3604df
index 5cf5eb0..f3ce463 100644
3604df
--- a/geo-replication/syncdaemon/resource.py
3604df
+++ b/geo-replication/syncdaemon/resource.py
3604df
@@ -781,7 +781,23 @@ class Server(object):
3604df
                     else:
3604df
                         if st.st_ino == st1.st_ino:
3604df
                             # we have a hard link, we can now unlink source
3604df
-                            os.unlink(entry)
3604df
+                            try:
3604df
+                                os.unlink(entry)
3604df
+                            except OSError as e:
3604df
+                                if e.errno == EISDIR:
3604df
+                                    try:
3604df
+                                        os.rmdir(entry)
3604df
+                                    except OSError as e:
3604df
+                                        if e.errno == ENOTEMPTY:
3604df
+                                            logging.error(
3604df
+                                                "Unable to delete directory "
3604df
+                                                "{0}, Both Old({1}) and New{2}"
3604df
+                                                " directories exists".format(
3604df
+                                                    entry, entry, en))
3604df
+                                        else:
3604df
+                                            raise
3604df
+                                else:
3604df
+                                    raise
3604df
                         else:
3604df
                             rename_with_disk_gfid_confirmation(gfid, entry, en)
3604df
             if blob:
3604df
-- 
3604df
2.9.3
3604df