Fix diagnostics path to not include the parent dir structure Without the fix, the diagnostics tar file included the entire directory structure of the diagnostics root dir.
Before: ======= $ tar tf /tmp/impala-diagnostics-2018-05-08-11-59-39-spv8Eh.tar.gz tmp/impala-diagnostics-2018-05-08-11-59-39-spv8Eh/ tmp/impala-diagnostics-2018-05-08-11-59-39-spv8Eh/stacks/ tmp/impala-diagnostics-2018-05-08-11-59-39-spv8Eh/stacks/jstack-0.txt .... After: ===== $ tar tf /tmp/impala-diagnostics-2018-05-08-12-01-51-Y0nlQI.tar.gz impala-diagnostics-2018-05-08-12-01-51-Y0nlQI/ impala-diagnostics-2018-05-08-12-01-51-Y0nlQI/stacks/ impala-diagnostics-2018-05-08-12-01-51-Y0nlQI/stacks/jstack-0.txt ..... Tested with python 2.6 Change-Id: I540f6c228a0315780d45cf11961f124478b5dd0c Reviewed-on: http://gerrit.cloudera.org:8080/10347 Reviewed-by: Bharath Vissapragada <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/impala/repo Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/3e736450 Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/3e736450 Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/3e736450 Branch: refs/heads/master Commit: 3e736450354e55244e16924cfeb223a30629351d Parents: b126b2d Author: Bharath Vissapragada <[email protected]> Authored: Tue May 8 12:03:35 2018 -0700 Committer: Impala Public Jenkins <[email protected]> Committed: Thu May 10 09:29:55 2018 +0000 ---------------------------------------------------------------------- bin/diagnostics/collect_diagnostics.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/impala/blob/3e736450/bin/diagnostics/collect_diagnostics.py ---------------------------------------------------------------------- diff --git a/bin/diagnostics/collect_diagnostics.py b/bin/diagnostics/collect_diagnostics.py index 8fe4561..56b5595 100644 --- a/bin/diagnostics/collect_diagnostics.py +++ b/bin/diagnostics/collect_diagnostics.py @@ -447,7 +447,10 @@ class ImpalaDiagnosticsHandler(object): # around that. with closing(tarfile.open(self.collection_root_dir + '.tar.gz', mode='w:gz')) as\ archive: - archive.add(self.collection_root_dir) + # collection_root_dir is an absoulte path. There is no point in preserving its + # entire directory structure in the archive, so set the arcname accordingly. + archive.add(self.collection_root_dir, + arcname=os.path.basename(self.collection_root_dir)) return True except Exception: logging.exception("Encountered an exception archiving diagnostics, cleaning up.")
