Bug#928938: cronic: Add option to report on return status only

2019-05-17 Thread Chuck Houpt
Thanks for the clarification Dave. I definitely appreciate the problem of tools 
overusing stderr -- I've run into it, and much of my Cronic support email is 
about the problem.

However, I don't thinking adding a global stderr suppression option is a good 
idea. Here's my reasons:

Principle - Suppressing error output will miss important diagnostic messages. 
Not all stderr output is accompanied by an error-code. In particular, warnings 
are stderr output that don't prevent a tool from succeeding. Typical examples 
of warnings are deprecation warnings from interpreters/compilers, or security 
config warnings. Cronic should always assumes that any tool or script may 
succeed, but output warnings at any time.

Social - I fear a global suppression option would quickly become the 
"recommended" usage for Cronic, which would defeat much of its utility. At the 
first sign of trouble, users will search around and find the global suppression 
option, rather then address the specific tool's problem.

Practical - The extraneous stderr output can be suppressed locally in cron 
scripts by redirect the tool's stderr to stdout, or elsewhere. For example:

gitlab-ctl ... 2>&1

Or the one-liner version with eval:

cronic eval 'gitlab-ctl ... 2>&1'

Of course, it is important to realize that one is kludging or bodging the 
problem here, and true warnings or errors may be missed. The only real solution 
is to fix the tool. At least by using the ugly "2>&1", the misbehaving tool is 
clearly marked.

Cheers - Chuck


Bug#928938: cronic: Add option to report on return status only

2019-05-15 Thread Dave Page

On 15/05/2019 18:40, wrote:

Hi all, Thanks for including me in the conversation. To start, I want to 
confirm that we are specifically taking about the debug-trace standard-error 
output of docker/gitlab/etc (typically activated with a -D/--debug option), and 
not the normal output of such programs?

I ask because cronic has primitive support for ignoring debug-trace output on 
standard-error via the PS4 environment variable, so maybe a new option isn't 
needed? Or maybe the PS4 mechanism needs enhancing...

Cheers - Chuck


Hi Chuck,

No, this isn't specifically-requested debug information.

A command like "gitlab-ctl registry-garbage-collect -m" produce a whole 
lot of informational-level output on STDERR while returning a 0 error 
code. There's nothing you can pass to that script which will silence 
that, and it's the recommended / supported way of performing that 
garbage collection.


Cheers,
Dave

--
Dave Page, Operations Team ManagerCodethink Ltd
Telephone: +44 7762 840 4143rd Floor Dale House, 35 Dale Street
http://www.codethink.co.uk/   Manchester M1 2HF, United Kingdom
We respect your privacy.   See https://www.codethink.co.uk/privacy.html



Bug#928938: cronic: Add option to report on return status only

2019-05-15 Thread Chuck Houpt
Hi all, Thanks for including me in the conversation. To start, I want to 
confirm that we are specifically taking about the debug-trace standard-error 
output of docker/gitlab/etc (typically activated with a -D/--debug option), and 
not the normal output of such programs?

I ask because cronic has primitive support for ignoring debug-trace output on 
standard-error via the PS4 environment variable, so maybe a new option isn't 
needed? Or maybe the PS4 mechanism needs enhancing...

Cheers - Chuck



Bug#928938: cronic: Add option to report on return status only

2019-05-15 Thread Daniel Lange

Hi Dave

Am 13.05.19 um 18:46 schrieb Dave Page:

We have locally patched our cronic to support an option, -r, which will
cause cronic to only generate a report if the return code is nonzero,
even if there is STDERR output. We submit it for your consideration.


Thank you very much for sharing your patch and the rationale for it.

I've asked Chuck (CC), the upstream author, whether he wants to add this 
feature into his software.


Let's see what he says.

Kind regards,
Daniel



Bug#928938: cronic: Add option to report on return status only

2019-05-13 Thread Dave Page
Package: cronic
Version: 3-1
Severity: wishlist
Tags: patch upstream

Dear Maintainer,

An increasing number of applications we use through cron are putting
debug output on STDERR while returning 0 by default, and cannot be
quietened. Examples include docker and gitlab maintenance

We have locally patched our cronic to support an option, -r, which will
cause cronic to only generate a report if the return code is nonzero,
even if there is STDERR output. We submit it for your consideration.

-- System Information:
Debian Release: 9.9
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-9-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages cronic depends on:
ii  bash  4.4-5

cronic recommends no packages.

Versions of packages cronic suggests:
ii  cron  3.0pl1-128+deb9u1

-- no debconf information
--- cronic.orig 2019-05-13 17:46:13.150590183 +0100
+++ cronic  2019-05-13 17:19:01.098080693 +0100
@@ -11,6 +11,18 @@
 ERR=$TMP/cronic.err
 TRACE=$TMP/cronic.trace
 
+CRONIC_RESULT_ONLY=""
+
+# Go over $@ to look for - parameters
+while getopts r opt; do
+  case $opt in
+r)
+  CRONIC_RESULT_ONLY="yes"
+  ;;
+  esac
+done
+shift "$((OPTIND-1))"
+
 set +e
 "$@" >$OUT 2>$TRACE
 RESULT=$?
@@ -24,7 +36,7 @@
 ERR=$TRACE
 fi
 
-if [ $RESULT -ne 0 -o -s "$ERR" ]
+if [[ -n "$CRONIC_RESULT_ONLY" && $RESULT -ne 0 ]] || [[ -z 
"$CRONIC_RESULT_ONLY" && ( $RESULT -ne 0 || -s "$ERR" ) ]]
 then
 echo "Cronic detected failure or error output for the command:"
 echo "$@"