4c8e44
From 13809f57913cc5797d2a9d1ad19eb561a5113845 Mon Sep 17 00:00:00 2001
4c8e44
From: Ken Gaillot <kgaillot@redhat.com>
4c8e44
Date: Fri, 23 Aug 2019 17:28:49 -0500
4c8e44
Subject: [PATCH 1/5] Fix: tools: correct crm_report argument parsing
4c8e44
4c8e44
There were a few instances where crm_report's option names passed to getopt,
4c8e44
option names listed in help, and option names checked for did not match.
4c8e44
4c8e44
Where getopt and checks matched, I went with that, so that anything that
4c8e44
worked before continues to work.
4c8e44
---
4c8e44
 tools/crm_report.in | 10 ++++++----
4c8e44
 1 file changed, 6 insertions(+), 4 deletions(-)
4c8e44
4c8e44
diff --git a/tools/crm_report.in b/tools/crm_report.in
4c8e44
index d1bc425..0ccec56 100644
4c8e44
--- a/tools/crm_report.in
4c8e44
+++ b/tools/crm_report.in
4c8e44
@@ -10,7 +10,7 @@
4c8e44
 
4c8e44
 TEMP=`@GETOPT_PATH@			\
4c8e44
     -o hv?xl:f:t:n:T:L:p:c:dSCu:D:MVse:	\
4c8e44
-    --long help,cts:,cts-log:,dest:,node:,nodes:,from:,to:,sos-mode,logfile:,as-directory,single-node,cluster:,user:,max-depth:,version,features,rsh:	\
4c8e44
+    --long help,corosync,cts:,cts-log:,dest:,node:,nodes:,from:,to:,sos-mode,logfile:,as-directory,single-node,cluster:,user:,max-depth:,version,features,rsh:	\
4c8e44
     -n 'crm_report' -- "$@"`
4c8e44
 # The quotes around $TEMP are essential
4c8e44
 eval set -- "$TEMP"
4c8e44
@@ -44,6 +44,7 @@ Required option:
4c8e44
 
4c8e44
 Options:
4c8e44
   -V                    increase verbosity (may be specified multiple times)
4c8e44
+  -h, --help            display this message
4c8e44
   -v, --version         display software version
4c8e44
   --features            display software features
4c8e44
   -t, --to TIME         time at which all problems were resolved
4c8e44
@@ -65,9 +66,10 @@ Options:
4c8e44
   -C, --corosync        force the cluster type to be corosync
4c8e44
   -u, --user USER       username to use when collecting data from other nodes
4c8e44
                         (default root)
4c8e44
-  -D, --depth           search depth to use when attempting to locate files
4c8e44
+  -D, --max-depth       search depth to use when attempting to locate files
4c8e44
   -e, --rsh             command to use to run commands on other nodes
4c8e44
                         (default ssh -T)
4c8e44
+  -d, --as-directory    leave result as a directory tree instead of archiving
4c8e44
   --sos-mode            use defaults suitable for being called by sosreport tool
4c8e44
                         (behavior subject to change and not useful to end users)
4c8e44
   DEST, --dest DEST     custom destination directory or file name
4c8e44
@@ -107,13 +109,13 @@ while true; do
4c8e44
     case "$1" in
4c8e44
 	-x) set -x; shift;;
4c8e44
 	-V) verbose=`expr $verbose + 1`; shift;;
4c8e44
-	-T|--cts-test) tests="$tests $2"; shift; shift;;
4c8e44
+	-T|--cts) tests="$tests $2"; shift; shift;;
4c8e44
 	   --cts-log) ctslog="$2"; shift; shift;;
4c8e44
 	-f|--from) start_time=`get_time "$2"`; shift; shift;;
4c8e44
 	-t|--to) end_time=`get_time "$2"`; shift; shift;;
4c8e44
 	-n|--node|--nodes) nodes="$nodes $2"; shift; shift;;
4c8e44
 	-S|--single-node) nodes="$host"; shift;;
4c8e44
-	-E|-l|--logfile) extra_logs="$extra_logs $2"; shift; shift;;
4c8e44
+	-l|--logfile) extra_logs="$extra_logs $2"; shift; shift;;
4c8e44
 	-p) sanitize_patterns="$sanitize_patterns $2"; shift; shift;;
4c8e44
 	-L) log_patterns="$log_patterns `echo $2 | sed 's/ /\\\W/g'`"; shift; shift;;
4c8e44
 	-d|--as-directory) compress=0; shift;;
4c8e44
-- 
4c8e44
1.8.3.1
4c8e44
4c8e44
4c8e44
From 24f0cbb4423a98b41e629c915b79778b39b5ae22 Mon Sep 17 00:00:00 2001
4c8e44
From: Ken Gaillot <kgaillot@redhat.com>
4c8e44
Date: Fri, 23 Aug 2019 17:39:45 -0500
4c8e44
Subject: [PATCH 3/5] Fix: tools: don't ignore log if unrelated file is too
4c8e44
 large
4c8e44
4c8e44
This fixes a regression in 1.1.12: since cb420a04, findln_by_time() would skip
4c8e44
a log if any file in the current working directory (rather than the log itself)
4c8e44
was larger than 1GB.
4c8e44
---
4c8e44
 tools/report.common.in | 2 +-
4c8e44
 1 file changed, 1 insertion(+), 1 deletion(-)
4c8e44
4c8e44
diff --git a/tools/report.common.in b/tools/report.common.in
4c8e44
index 7dd00b3..4fed6bb 100644
4c8e44
--- a/tools/report.common.in
4c8e44
+++ b/tools/report.common.in
4c8e44
@@ -538,7 +538,7 @@ findln_by_time() {
4c8e44
     # Some logs can be massive (over 1,500,000,000 lines have been seen in the wild) 
4c8e44
     # Even just 'wc -l' on these files can take 10+ minutes 
4c8e44
 
4c8e44
-    local fileSize=`ls -lh | awk '{ print $5 }' | grep -ie G`
4c8e44
+    local fileSize=`ls -lh "$logf" | awk '{ print $5 }' | grep -ie G`
4c8e44
     if [ x$fileSize != x ]; then
4c8e44
         warning "$logf is ${fileSize} in size and could take many hours to process. Skipping."
4c8e44
         return
4c8e44
-- 
4c8e44
1.8.3.1
4c8e44
4c8e44
4c8e44
From 885d9acdb8132a437b48d4d9e8121131cbedb3da Mon Sep 17 00:00:00 2001
4c8e44
From: Ken Gaillot <kgaillot@redhat.com>
4c8e44
Date: Fri, 23 Aug 2019 22:38:51 -0500
4c8e44
Subject: [PATCH 4/5] Fix: tools: check for tar in crm_report
4c8e44
4c8e44
crm_report requires tar, so check for its existence up front.
4c8e44
---
4c8e44
 tools/crm_report.in       |  4 ++++
4c8e44
 tools/report.collector.in |  2 ++
4c8e44
 tools/report.common.in    | 10 ++++++++++
4c8e44
 3 files changed, 16 insertions(+)
4c8e44
4c8e44
diff --git a/tools/crm_report.in b/tools/crm_report.in
4c8e44
index 0ccec56..1818879 100644
4c8e44
--- a/tools/crm_report.in
4c8e44
+++ b/tools/crm_report.in
4c8e44
@@ -419,6 +419,10 @@ getnodes() {
4c8e44
     # TODO: Look for something like crm_update_peer
4c8e44
 }
4c8e44
 
4c8e44
+if [ $compress -eq 1 ]; then
4c8e44
+    require_tar
4c8e44
+fi
4c8e44
+
4c8e44
 if [ "x$tests" != "x" ]; then
4c8e44
     do_cts
4c8e44
 
4c8e44
diff --git a/tools/report.collector.in b/tools/report.collector.in
4c8e44
index 9419f17..315b785 100644
4c8e44
--- a/tools/report.collector.in
4c8e44
+++ b/tools/report.collector.in
4c8e44
@@ -747,6 +747,8 @@ collect_logs() {
4c8e44
     trap "" 0
4c8e44
 }
4c8e44
 
4c8e44
+require_tar
4c8e44
+
4c8e44
 debug "Initializing $REPORT_TARGET subdir"
4c8e44
 if [ "$REPORT_MASTER" != "$REPORT_TARGET" ]; then
4c8e44
   if [ -e $REPORT_HOME/$REPORT_TARGET ]; then
4c8e44
diff --git a/tools/report.common.in b/tools/report.common.in
4c8e44
index 4fed6bb..73ec0dc 100644
4c8e44
--- a/tools/report.common.in
4c8e44
+++ b/tools/report.common.in
4c8e44
@@ -114,6 +114,13 @@ fatal() {
4c8e44
     exit 1
4c8e44
 }
4c8e44
 
4c8e44
+require_tar() {
4c8e44
+    which tar >/dev/null 2>&1
4c8e44
+    if [ $? -ne 0 ]; then
4c8e44
+        fatal "Required program 'tar' not found, please install and re-run"
4c8e44
+    fi
4c8e44
+}
4c8e44
+
4c8e44
 # check if process of given substring in its name does exist;
4c8e44
 # only look for processes originated by user 0 (by UID), "@CRM_DAEMON_USER@"
4c8e44
 # or effective user running this script, and/or group 0 (by GID),
4c8e44
@@ -525,6 +532,9 @@ shrink() {
4c8e44
 
4c8e44
     cd $dir  >/dev/null 2>&1
4c8e44
     tar $tar_options $target $base >/dev/null 2>&1
4c8e44
+    if [ $? -ne 0 ]; then
4c8e44
+        fatal "Could not archive $base, please investigate and collect manually"
4c8e44
+    fi
4c8e44
     cd $olddir  >/dev/null 2>&1
4c8e44
 
4c8e44
     echo $target
4c8e44
-- 
4c8e44
1.8.3.1
4c8e44
4c8e44
4c8e44
From 5dcdb1eef727912fe33d7c8d9d2a4076fee7eb70 Mon Sep 17 00:00:00 2001
4c8e44
From: Ken Gaillot <kgaillot@redhat.com>
4c8e44
Date: Fri, 23 Aug 2019 22:15:50 -0500
4c8e44
Subject: [PATCH 5/5] Build: rpm: add soft dependency on tar and bzip2
4c8e44
4c8e44
... which are needed by crm_report. Minimal OS installations are increasingly
4c8e44
popular, and the existence of tar can't be assumed. These are soft dependencies
4c8e44
because they are only needed for crm_report, not cluster functioning, and a
4c8e44
soft dependency allows users to keep a smaller footprint if desired while
4c8e44
providing full functionality to the typical user.
4c8e44
---
4c8e44
 pacemaker.spec.in | 3 +++
4c8e44
 1 file changed, 3 insertions(+)
4c8e44
4c8e44
diff --git a/pacemaker.spec.in b/pacemaker.spec.in
4c8e44
index 0143b63..0f1638b 100644
4c8e44
--- a/pacemaker.spec.in
4c8e44
+++ b/pacemaker.spec.in
4c8e44
@@ -279,6 +279,9 @@ Group:         System Environment/Daemons
4c8e44
 Requires:      %{name}-libs%{?_isa} = %{version}-%{release}
4c8e44
 %if 0%{?fedora} > 22 || 0%{?rhel} > 7
4c8e44
 Recommends:    pcmk-cluster-manager = %{version}-%{release}
4c8e44
+# For crm_report
4c8e44
+Recommends:    tar
4c8e44
+Recommends:    bzip2
4c8e44
 %endif
4c8e44
 Requires:      perl-TimeDate
4c8e44
 Requires:      procps-ng
4c8e44
-- 
4c8e44
1.8.3.1
4c8e44