Catch ESTALE in addition to ENOENT
Change-Id: Icf0a9b79371890b9a4ac8ea522ff15f08a3c2e75 Signed-off-by: Prashanth Pai <ppai@redhat.com>
This commit is contained in:
parent
8d60b484e9
commit
b2dbc15e9b
gluster/swift
@ -177,7 +177,12 @@ class DiskCommon(object):
|
||||
def _dir_exists_read_metadata(self):
|
||||
self._dir_exists = do_exists(self.datadir)
|
||||
if self._dir_exists:
|
||||
self.metadata = _read_metadata(self.datadir)
|
||||
try:
|
||||
self.metadata = _read_metadata(self.datadir)
|
||||
except GlusterFileSystemIOError as err:
|
||||
if err.errno in (errno.ENOENT, errno.ESTALE):
|
||||
return False
|
||||
raise
|
||||
return self._dir_exists
|
||||
|
||||
def is_deleted(self):
|
||||
@ -366,7 +371,7 @@ class DiskDir(DiskCommon):
|
||||
try:
|
||||
metadata = read_metadata(obj_path)
|
||||
except GlusterFileSystemIOError as err:
|
||||
if err.errno == errno.ENOENT:
|
||||
if err.errno in (errno.ENOENT, errno.ESTALE):
|
||||
# obj might have been deleted by another process
|
||||
# since the objects list was originally built
|
||||
continue
|
||||
@ -382,7 +387,7 @@ class DiskDir(DiskCommon):
|
||||
except OSError as e:
|
||||
# FIXME - total hack to get upstream swift ported unit
|
||||
# test cases working for now.
|
||||
if e.errno != errno.ENOENT:
|
||||
if e.errno not in (errno.ENOENT, errno.ESTALE):
|
||||
raise
|
||||
if not Glusterfs._implicit_dir_objects and metadata \
|
||||
and metadata[X_CONTENT_TYPE] == DIR_TYPE \
|
||||
@ -681,7 +686,7 @@ class DiskAccount(DiskCommon):
|
||||
except OSError as e:
|
||||
# FIXME - total hack to get upstream swift ported unit
|
||||
# test cases working for now.
|
||||
if e.errno != errno.ENOENT:
|
||||
if e.errno not in (errno.ENOENT, errno.ESTALE):
|
||||
raise
|
||||
if metadata:
|
||||
list_item.append(metadata[X_OBJECTS_COUNT][0])
|
||||
|
@ -162,7 +162,7 @@ def dir_empty(path):
|
||||
files = do_listdir(path)
|
||||
return not files
|
||||
except GlusterFileSystemOSError as err:
|
||||
if err.errno == errno.ENOENT:
|
||||
if err.errno in (errno.ENOENT, errno.ESTALE):
|
||||
raise FileOrDirNotFoundError()
|
||||
if err.errno == errno.ENOTDIR:
|
||||
raise NotDirectoryError()
|
||||
@ -210,7 +210,7 @@ def do_stat(path):
|
||||
serr = err
|
||||
sleep(random.uniform(0.001, 0.005))
|
||||
continue
|
||||
if err.errno == errno.ENOENT:
|
||||
if err.errno in (errno.ENOENT, errno.ESTALE):
|
||||
stats = None
|
||||
else:
|
||||
raise GlusterFileSystemOSError(
|
||||
@ -268,7 +268,7 @@ def do_unlink(path, log=True):
|
||||
try:
|
||||
os.unlink(path)
|
||||
except OSError as err:
|
||||
if err.errno != errno.ENOENT:
|
||||
if err.errno not in (errno.ENOENT, errno.ESTALE):
|
||||
raise GlusterFileSystemOSError(
|
||||
err.errno, '%s, os.unlink("%s")' % (err.strerror, path))
|
||||
else:
|
||||
|
@ -246,7 +246,7 @@ def _update_list(path, cont_path, src_list, reg_file=True, object_count=0,
|
||||
metadata = \
|
||||
read_metadata(os.path.join(cont_path, obj_path, obj_name))
|
||||
except GlusterFileSystemIOError as err:
|
||||
if err.errno == errno.ENOENT:
|
||||
if err.errno in (errno.ENOENT, errno.ESTALE):
|
||||
# object might have been deleted by another process
|
||||
# since the src_list was originally built
|
||||
continue
|
||||
@ -484,7 +484,7 @@ def rmobjdir(dir_path):
|
||||
try:
|
||||
do_rmdir(dir_path)
|
||||
except OSError as err:
|
||||
if err.errno == errno.ENOENT:
|
||||
if err.errno in (errno.ENOENT, errno.ESTALE):
|
||||
# No such directory exists
|
||||
return False
|
||||
if err.errno != errno.ENOTEMPTY:
|
||||
@ -503,7 +503,7 @@ def rmobjdir(dir_path):
|
||||
try:
|
||||
metadata = read_metadata(fullpath)
|
||||
except GlusterFileSystemIOError as err:
|
||||
if err.errno == errno.ENOENT:
|
||||
if err.errno in (errno.ENOENT, errno.ESTALE):
|
||||
# Ignore removal from another entity.
|
||||
continue
|
||||
raise
|
||||
@ -521,7 +521,7 @@ def rmobjdir(dir_path):
|
||||
if err.errno == errno.ENOTEMPTY:
|
||||
# Directory is not empty, it might have objects in it
|
||||
return False
|
||||
if err.errno == errno.ENOENT:
|
||||
if err.errno in (errno.ENOENT, errno.ESTALE):
|
||||
# No such directory exists, already removed, ignore
|
||||
continue
|
||||
raise
|
||||
@ -532,7 +532,7 @@ def rmobjdir(dir_path):
|
||||
if err.errno == errno.ENOTEMPTY:
|
||||
# Directory is not empty, race with object creation
|
||||
return False
|
||||
if err.errno == errno.ENOENT:
|
||||
if err.errno in (errno.ENOENT, errno.ESTALE):
|
||||
# No such directory exists, already removed, ignore
|
||||
return True
|
||||
raise
|
||||
|
@ -675,12 +675,13 @@ class DiskFile(object):
|
||||
# Something went wrong. Context manager will not call
|
||||
# __exit__. So we close the fd manually here.
|
||||
self._close_fd()
|
||||
if hasattr(err, 'errno') and err.errno == errno.ENOENT:
|
||||
# Handle races: ENOENT can be raised by read_metadata()
|
||||
if hasattr(err, 'errno') and \
|
||||
err.errno in (errno.ENOENT, errno.ESTALE):
|
||||
# Handle races: ENOENT/ESTALE can be raised by read_metadata()
|
||||
# call in GlusterFS if file gets deleted by another
|
||||
# client after do_open() succeeds
|
||||
logging.warn("open(%s) succeeded but one of the subsequent "
|
||||
"syscalls failed with ENOENT. Raising "
|
||||
"syscalls failed with ENOENT/ESTALE. Raising "
|
||||
"DiskFileNotExist." % (self._data_file))
|
||||
raise DiskFileNotExist
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user