summaryrefslogtreecommitdiffstats
path: root/tools/glusterfind
diff options
context:
space:
mode:
authorMilind Changire <mchangir@redhat.com>2015-06-12 12:48:27 +0530
committerVijay Bellur <vbellur@redhat.com>2015-06-12 07:13:18 -0700
commitb0edf64f91bf2afefc811c832babe9e3e6bdfbfe (patch)
treebdd0bc2bc039da506f91d95fa699c3b09843f650 /tools/glusterfind
parente58b55ed9b2e802e6c3e908cbbad71c00f6c5b97 (diff)
tools/glusterfind: ignoring deleted files
OSError and IOError exceptions were being thrown if files were deleted after session was created and a subsequent glusterfind pre was attmepted. glusterfind now detects this scenario and safely ignores these changes to the file-system. We also avoid recording deleted file paths into database in the case where gfid to path resolution cannot be performed for deleted files. Also, we now turn on volume option to capture delete paths. Change-Id: Iaf3883463f5e64643497bd77229ad80a9b2d5da5 BUG: 1228111 Signed-off-by: Milind Changire <mchangir@redhat.com> Reviewed-on: http://review.gluster.org/11194 Reviewed-by: Aravinda VK <avishwan@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'tools/glusterfind')
-rw-r--r--tools/glusterfind/src/changelog.py60
-rw-r--r--tools/glusterfind/src/main.py7
2 files changed, 43 insertions, 24 deletions
diff --git a/tools/glusterfind/src/changelog.py b/tools/glusterfind/src/changelog.py
index fd2384b..5939d48 100644
--- a/tools/glusterfind/src/changelog.py
+++ b/tools/glusterfind/src/changelog.py
@@ -61,10 +61,13 @@ def pgfid_to_path(brick, changelog_data):
if row[0] == "":
continue
- path = symlink_gfid_to_path(brick, row[0])
- path = output_path_prepare(path, args.output_prefix)
-
- changelog_data.gfidpath_set_path1(path, row[0])
+ try:
+ path = symlink_gfid_to_path(brick, row[0])
+ path = output_path_prepare(path, args.output_prefix)
+ changelog_data.gfidpath_set_path1(path, row[0])
+ except (IOError, OSError) as e:
+ logger.warn("Error converting to path: %s" % e)
+ continue
# pgfid2 to path2 in case of RENAME
for row in changelog_data.gfidpath_get_distinct("pgfid2",
@@ -74,13 +77,14 @@ def pgfid_to_path(brick, changelog_data):
if row[0] == "":
continue
- path = symlink_gfid_to_path(brick, row[0])
- if path == "":
+ try:
+ path = symlink_gfid_to_path(brick, row[0])
+ path = output_path_prepare(path, args.output_prefix)
+ changelog_data.gfidpath_set_path2(path, row[0])
+ except (IOError, OSError) as e:
+ logger.warn("Error converting to path: %s" % e)
continue
- path = output_path_prepare(path, args.output_prefix)
- changelog_data.gfidpath_set_path2(path, row[0])
-
def populate_pgfid_and_inodegfid(brick, changelog_data):
"""
@@ -94,14 +98,14 @@ def populate_pgfid_and_inodegfid(brick, changelog_data):
p = os.path.join(brick, ".glusterfs", gfid[0:2], gfid[2:4], gfid)
if os.path.islink(p):
# It is a Directory if GFID backend path is symlink
- path = symlink_gfid_to_path(brick, gfid)
- if path == "":
+ try:
+ path = symlink_gfid_to_path(brick, gfid)
+ path = output_path_prepare(path, args.output_prefix)
+ changelog_data.gfidpath_update({"path1": path},
+ {"gfid": gfid})
+ except (IOError, OSError) as e:
+ logger.warn("Error converting to path: %s" % e)
continue
-
- path = output_path_prepare(path, args.output_prefix)
-
- changelog_data.gfidpath_update({"path1": path},
- {"gfid": gfid})
else:
try:
# INODE and GFID to inodegfid table
@@ -161,12 +165,16 @@ def gfid_to_path_using_pgfid(brick, changelog_data, args):
conf.get_opt("brick_ignore_dirs").split(",")]
for row in changelog_data.pgfid_get():
- path = symlink_gfid_to_path(brick, row[0])
- find(os.path.join(brick, path),
- callback_func=output_callback,
- filter_func=inode_filter,
- ignore_dirs=ignore_dirs,
- subdirs_crawl=False)
+ try:
+ path = symlink_gfid_to_path(brick, row[0])
+ find(os.path.join(brick, path),
+ callback_func=output_callback,
+ filter_func=inode_filter,
+ ignore_dirs=ignore_dirs,
+ subdirs_crawl=False)
+ except (IOError, OSError) as e:
+ logger.warn("Error converting to path: %s" % e)
+ continue
def gfid_to_path_using_batchfind(brick, changelog_data):
@@ -291,8 +299,12 @@ def get_changes(brick, hash_dir, log_file, start, end, args):
# again in list
if change.endswith(".%s" % start):
continue
- parse_changelog_to_db(changelog_data, change)
- libgfchangelog.cl_history_done(change)
+ try:
+ parse_changelog_to_db(changelog_data, change)
+ libgfchangelog.cl_history_done(change)
+ except IOError as e:
+ logger.warn("Error parsing changelog file %s: %s" %
+ (change, e))
changelog_data.commit()
except libgfchangelog.ChangelogException as e:
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
index 850024b..5d5058f 100644
--- a/tools/glusterfind/src/main.py
+++ b/tools/glusterfind/src/main.py
@@ -352,6 +352,13 @@ def mode_create(session_dir, args):
logger.info("Volume option set %s, changelog.changelog on"
% args.volume)
+ execute(["gluster", "volume", "set",
+ args.volume, "changelog.capture-del-path", "on"],
+ exit_msg="Failed to set volume option "
+ "changelog.capture-del-path on", logger=logger)
+ logger.info("Volume option set %s, changelog.capture-del-path on"
+ % args.volume)
+
# Add Rollover time to current time to make sure changelogs
# will be available if we use this time as start time
time_to_update = int(time.time()) + get_changelog_rollover_time(