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