|
|
21ab4e |
From f0a3a0de87cb215fb6b9d5451d04af720080decd Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Milind Changire <mchangir@redhat.com>
|
|
|
21ab4e |
Date: Mon, 12 Jun 2017 14:06:50 +0530
|
|
|
21ab4e |
Subject: [PATCH 497/509] tools/glusterfind: add --end-time option
|
|
|
21ab4e |
|
|
|
21ab4e |
Add optional --end-time argument to be used with --since-time
|
|
|
21ab4e |
when using the "query" command.
|
|
|
21ab4e |
|
|
|
21ab4e |
"start" and "end" times are passed in the command-line to
|
|
|
21ab4e |
changelog.py only if --full has not been specified on command-line.
|
|
|
21ab4e |
-1 is passed to changelog.py as end time if user has not supplied
|
|
|
21ab4e |
--end-time on command-line.
|
|
|
21ab4e |
|
|
|
21ab4e |
brickfind.py:
|
|
|
21ab4e |
Remove unused "start" command-line argument.
|
|
|
21ab4e |
|
|
|
21ab4e |
Also:
|
|
|
21ab4e |
Minor indentation changes to keep flake8-2.7 happy.
|
|
|
21ab4e |
|
|
|
21ab4e |
mainline:
|
|
|
21ab4e |
> BUG: 1453151
|
|
|
21ab4e |
> Reviewed-on: https://review.gluster.org/17439
|
|
|
21ab4e |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> Reviewed-by: Aravinda VK <avishwan@redhat.com>
|
|
|
21ab4e |
(cherry picked from commit dbdf56ae3f87fc2765ad9cb528c1cfbadfde96ec)
|
|
|
21ab4e |
|
|
|
21ab4e |
Change-Id: I063ef5459916f711503881ade5c4fc32374edad0
|
|
|
21ab4e |
BUG: 1450722
|
|
|
21ab4e |
Signed-off-by: Milind Changire <mchangir@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/108769
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
tools/glusterfind/src/brickfind.py | 2 +-
|
|
|
21ab4e |
tools/glusterfind/src/changelog.py | 27 ++++++++++++++-----------
|
|
|
21ab4e |
tools/glusterfind/src/main.py | 40 ++++++++++++++++++++++++++------------
|
|
|
21ab4e |
3 files changed, 45 insertions(+), 24 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/tools/glusterfind/src/brickfind.py b/tools/glusterfind/src/brickfind.py
|
|
|
21ab4e |
index 439c881..e914bac 100644
|
|
|
21ab4e |
--- a/tools/glusterfind/src/brickfind.py
|
|
|
21ab4e |
+++ b/tools/glusterfind/src/brickfind.py
|
|
|
21ab4e |
@@ -62,9 +62,9 @@ def _get_args():
|
|
|
21ab4e |
|
|
|
21ab4e |
parser.add_argument("session", help="Session Name")
|
|
|
21ab4e |
parser.add_argument("volume", help="Volume Name")
|
|
|
21ab4e |
+ parser.add_argument("node", help="Node Name")
|
|
|
21ab4e |
parser.add_argument("brick", help="Brick Name")
|
|
|
21ab4e |
parser.add_argument("outfile", help="Output File")
|
|
|
21ab4e |
- parser.add_argument("start", help="Start Time", type=float)
|
|
|
21ab4e |
parser.add_argument("tag", help="Tag to prefix file name with")
|
|
|
21ab4e |
parser.add_argument("--only-query", help="Only query, No session update",
|
|
|
21ab4e |
action="store_true")
|
|
|
21ab4e |
diff --git a/tools/glusterfind/src/changelog.py b/tools/glusterfind/src/changelog.py
|
|
|
21ab4e |
index 721b8d0..ec38bfa 100644
|
|
|
21ab4e |
--- a/tools/glusterfind/src/changelog.py
|
|
|
21ab4e |
+++ b/tools/glusterfind/src/changelog.py
|
|
|
21ab4e |
@@ -40,8 +40,6 @@ history_turn_time = 0
|
|
|
21ab4e |
logger = logging.getLogger()
|
|
|
21ab4e |
|
|
|
21ab4e |
|
|
|
21ab4e |
-
|
|
|
21ab4e |
-
|
|
|
21ab4e |
def pgfid_to_path(brick, changelog_data):
|
|
|
21ab4e |
"""
|
|
|
21ab4e |
For all the pgfids in table, converts into path using recursive
|
|
|
21ab4e |
@@ -94,7 +92,7 @@ def populate_pgfid_and_inodegfid(brick, changelog_data):
|
|
|
21ab4e |
path = symlink_gfid_to_path(brick, gfid)
|
|
|
21ab4e |
path = output_path_prepare(path, args)
|
|
|
21ab4e |
changelog_data.gfidpath_update({"path1": path},
|
|
|
21ab4e |
- {"gfid": gfid})
|
|
|
21ab4e |
+ {"gfid": gfid})
|
|
|
21ab4e |
except (IOError, OSError) as e:
|
|
|
21ab4e |
logger.warn("Error converting to path: %s" % e)
|
|
|
21ab4e |
continue
|
|
|
21ab4e |
@@ -160,10 +158,10 @@ def gfid_to_path_using_pgfid(brick, changelog_data, args):
|
|
|
21ab4e |
try:
|
|
|
21ab4e |
path = symlink_gfid_to_path(brick, row[0])
|
|
|
21ab4e |
find(os.path.join(brick, path),
|
|
|
21ab4e |
- callback_func=output_callback,
|
|
|
21ab4e |
- filter_func=inode_filter,
|
|
|
21ab4e |
- ignore_dirs=ignore_dirs,
|
|
|
21ab4e |
- subdirs_crawl=False)
|
|
|
21ab4e |
+ callback_func=output_callback,
|
|
|
21ab4e |
+ filter_func=inode_filter,
|
|
|
21ab4e |
+ ignore_dirs=ignore_dirs,
|
|
|
21ab4e |
+ subdirs_crawl=False)
|
|
|
21ab4e |
except (IOError, OSError) as e:
|
|
|
21ab4e |
logger.warn("Error converting to path: %s" % e)
|
|
|
21ab4e |
continue
|
|
|
21ab4e |
@@ -272,8 +270,8 @@ def get_changes(brick, hash_dir, log_file, start, end, args):
|
|
|
21ab4e |
actual_end = libgfchangelog.cl_history_changelog(
|
|
|
21ab4e |
cl_path, start, end, CHANGELOGAPI_NUM_WORKERS)
|
|
|
21ab4e |
except libgfchangelog.ChangelogException as e:
|
|
|
21ab4e |
- fail("%s Historical Changelogs not available: %s" % (brick, e),
|
|
|
21ab4e |
- logger=logger)
|
|
|
21ab4e |
+ fail("%s: %s Historical Changelogs not available: %s" %
|
|
|
21ab4e |
+ (args.node, brick, e), logger=logger)
|
|
|
21ab4e |
|
|
|
21ab4e |
try:
|
|
|
21ab4e |
# scan followed by getchanges till scan returns zero.
|
|
|
21ab4e |
@@ -296,7 +294,7 @@ def get_changes(brick, hash_dir, log_file, start, end, args):
|
|
|
21ab4e |
libgfchangelog.cl_history_done(change)
|
|
|
21ab4e |
except IOError as e:
|
|
|
21ab4e |
logger.warn("Error parsing changelog file %s: %s" %
|
|
|
21ab4e |
- (change, e))
|
|
|
21ab4e |
+ (change, e))
|
|
|
21ab4e |
|
|
|
21ab4e |
changelog_data.commit()
|
|
|
21ab4e |
except libgfchangelog.ChangelogException as e:
|
|
|
21ab4e |
@@ -350,9 +348,11 @@ def _get_args():
|
|
|
21ab4e |
|
|
|
21ab4e |
parser.add_argument("session", help="Session Name")
|
|
|
21ab4e |
parser.add_argument("volume", help="Volume Name")
|
|
|
21ab4e |
+ parser.add_argument("node", help="Node Name")
|
|
|
21ab4e |
parser.add_argument("brick", help="Brick Name")
|
|
|
21ab4e |
parser.add_argument("outfile", help="Output File")
|
|
|
21ab4e |
parser.add_argument("start", help="Start Time", type=int)
|
|
|
21ab4e |
+ parser.add_argument("end", help="End Time", type=int)
|
|
|
21ab4e |
parser.add_argument("--only-query", help="Query mode only (no session)",
|
|
|
21ab4e |
action="store_true")
|
|
|
21ab4e |
parser.add_argument("--debug", help="Debug", action="store_true")
|
|
|
21ab4e |
@@ -387,6 +387,7 @@ if __name__ == "__main__":
|
|
|
21ab4e |
|
|
|
21ab4e |
if args.only_query:
|
|
|
21ab4e |
start = args.start
|
|
|
21ab4e |
+ end = args.end
|
|
|
21ab4e |
else:
|
|
|
21ab4e |
try:
|
|
|
21ab4e |
with open(status_file) as f:
|
|
|
21ab4e |
@@ -394,7 +395,11 @@ if __name__ == "__main__":
|
|
|
21ab4e |
except (ValueError, OSError, IOError):
|
|
|
21ab4e |
start = args.start
|
|
|
21ab4e |
|
|
|
21ab4e |
- end = int(time.time()) - get_changelog_rollover_time(args.volume)
|
|
|
21ab4e |
+ # end time is optional; so a -1 may be sent to use the default method of
|
|
|
21ab4e |
+ # identifying the end time
|
|
|
21ab4e |
+ if end == -1:
|
|
|
21ab4e |
+ end = int(time.time()) - get_changelog_rollover_time(args.volume)
|
|
|
21ab4e |
+
|
|
|
21ab4e |
logger.info("%s Started Changelog Crawl - Start: %s End: %s" % (args.brick,
|
|
|
21ab4e |
start,
|
|
|
21ab4e |
end))
|
|
|
21ab4e |
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
|
|
|
21ab4e |
index 8e31a07..df49e3d 100644
|
|
|
21ab4e |
--- a/tools/glusterfind/src/main.py
|
|
|
21ab4e |
+++ b/tools/glusterfind/src/main.py
|
|
|
21ab4e |
@@ -139,9 +139,11 @@ def run_cmd_nodes(task, args, **kwargs):
|
|
|
21ab4e |
cmd = [change_detector,
|
|
|
21ab4e |
args.session,
|
|
|
21ab4e |
args.volume,
|
|
|
21ab4e |
+ host,
|
|
|
21ab4e |
brick,
|
|
|
21ab4e |
- node_outfile,
|
|
|
21ab4e |
- str(kwargs.get("start"))] + \
|
|
|
21ab4e |
+ node_outfile] + \
|
|
|
21ab4e |
+ ([str(kwargs.get("start")), str(kwargs.get("end"))]
|
|
|
21ab4e |
+ if not args.full else []) + \
|
|
|
21ab4e |
([tag] if tag is not None else []) + \
|
|
|
21ab4e |
["--output-prefix", args.output_prefix] + \
|
|
|
21ab4e |
(["--debug"] if args.debug else []) + \
|
|
|
21ab4e |
@@ -174,9 +176,11 @@ def run_cmd_nodes(task, args, **kwargs):
|
|
|
21ab4e |
cmd = [change_detector,
|
|
|
21ab4e |
args.session,
|
|
|
21ab4e |
args.volume,
|
|
|
21ab4e |
+ host,
|
|
|
21ab4e |
brick,
|
|
|
21ab4e |
- node_outfile,
|
|
|
21ab4e |
- str(kwargs.get("start"))] + \
|
|
|
21ab4e |
+ node_outfile] + \
|
|
|
21ab4e |
+ ([str(kwargs.get("start")), str(kwargs.get("end"))]
|
|
|
21ab4e |
+ if not args.full else []) + \
|
|
|
21ab4e |
([tag] if tag is not None else []) + \
|
|
|
21ab4e |
["--only-query"] + \
|
|
|
21ab4e |
["--output-prefix", args.output_prefix] + \
|
|
|
21ab4e |
@@ -353,6 +357,8 @@ def _get_args():
|
|
|
21ab4e |
action=StoreAbsPath)
|
|
|
21ab4e |
parser_query.add_argument("--since-time", help="UNIX epoch time since "
|
|
|
21ab4e |
"which listing is required", type=int)
|
|
|
21ab4e |
+ parser_query.add_argument("--end-time", help="UNIX epoch time upto "
|
|
|
21ab4e |
+ "which listing is required", type=int)
|
|
|
21ab4e |
parser_query.add_argument("--no-encode",
|
|
|
21ab4e |
help="Do not encode path in output file",
|
|
|
21ab4e |
action="store_true")
|
|
|
21ab4e |
@@ -560,27 +566,37 @@ def mode_query(session_dir, args):
|
|
|
21ab4e |
enable_volume_options(args)
|
|
|
21ab4e |
|
|
|
21ab4e |
# Test options
|
|
|
21ab4e |
- if not args.since_time and not args.full:
|
|
|
21ab4e |
- fail("Please specify either --since-time or --full", logger=logger)
|
|
|
21ab4e |
+ if not args.since_time and not args.end_time and not args.full:
|
|
|
21ab4e |
+ fail("Please specify either {--since-time and optionally --end-time} "
|
|
|
21ab4e |
+ "or --full", logger=logger)
|
|
|
21ab4e |
|
|
|
21ab4e |
- if args.since_time and args.full:
|
|
|
21ab4e |
- fail("Please specify either --since-time or --full, but not both",
|
|
|
21ab4e |
+ if args.since_time and args.end_time and args.full:
|
|
|
21ab4e |
+ fail("Please specify either {--since-time and optionally --end-time} "
|
|
|
21ab4e |
+ "or --full, but not both",
|
|
|
21ab4e |
logger=logger)
|
|
|
21ab4e |
|
|
|
21ab4e |
+ if args.end_time and not args.since_time:
|
|
|
21ab4e |
+ fail("Please specify --since-time as well", logger=logger)
|
|
|
21ab4e |
+
|
|
|
21ab4e |
# Start query command processing
|
|
|
21ab4e |
+ start = -1
|
|
|
21ab4e |
+ end = -1
|
|
|
21ab4e |
if args.since_time:
|
|
|
21ab4e |
start = args.since_time
|
|
|
21ab4e |
+ if args.end_time:
|
|
|
21ab4e |
+ end = args.end_time
|
|
|
21ab4e |
else:
|
|
|
21ab4e |
start = 0 # --full option is handled separately
|
|
|
21ab4e |
|
|
|
21ab4e |
logger.debug("Query is called - Session: %s, Volume: %s, "
|
|
|
21ab4e |
- "Start time: %s"
|
|
|
21ab4e |
- % ("default", args.volume, start))
|
|
|
21ab4e |
+ "Start time: %s, End time: %s"
|
|
|
21ab4e |
+ % ("default", args.volume, start, end))
|
|
|
21ab4e |
|
|
|
21ab4e |
prefix = datetime.now().strftime("%Y%m%d-%H%M%S-%f-")
|
|
|
21ab4e |
gtmpfilename = prefix + next(tempfile._get_candidate_names())
|
|
|
21ab4e |
|
|
|
21ab4e |
- run_cmd_nodes("query", args, start=start, tmpfilename=gtmpfilename)
|
|
|
21ab4e |
+ run_cmd_nodes("query", args, start=start, end=end,
|
|
|
21ab4e |
+ tmpfilename=gtmpfilename)
|
|
|
21ab4e |
|
|
|
21ab4e |
# Merger
|
|
|
21ab4e |
if args.full:
|
|
|
21ab4e |
@@ -639,7 +655,7 @@ def mode_pre(session_dir, args):
|
|
|
21ab4e |
prefix = datetime.now().strftime("%Y%m%d-%H%M%S-%f-")
|
|
|
21ab4e |
gtmpfilename = prefix + next(tempfile._get_candidate_names())
|
|
|
21ab4e |
|
|
|
21ab4e |
- run_cmd_nodes("pre", args, start=start, tmpfilename=gtmpfilename)
|
|
|
21ab4e |
+ run_cmd_nodes("pre", args, start=start, end=-1, tmpfilename=gtmpfilename)
|
|
|
21ab4e |
|
|
|
21ab4e |
# Merger
|
|
|
21ab4e |
if args.full:
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|