[MXS-4175] maxctrl writes error messages to stdout instead of stderr Created: 2022-06-23  Updated: 2022-06-30  Resolved: 2022-06-27

Status: Closed
Project: MariaDB MaxScale
Component/s: maxctrl
Affects Version/s: 6.2.4
Fix Version/s: 22.08.0

Type: Bug Priority: Major
Reporter: Assen Totin (Inactive) Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None


 Description   

When maxctrl fails to run a command, it prints an error message (and sets the exit code to be greater than zero).

In Unix (and hence Linux), each process has two output file descriptors: Standard Output (stdout) and Standard Error (stderr). The purpose of the first is to get common messages from the program - e.g., notices, information etc. The purpose of the second is to specifically get only error messages. This convention is important as many tools that may call a program will check its exit code and, if greater than zero, will log its Standard Error only.

maxctrl does not comply with these rules as it always prints its messages, even error messages, to stdout (on the Linux shell file descriptors are assigned integers for convenience, with 1 being stdout and 2 being stderr):

[root@p2w4 ~]# maxctrl lala > stdout 2>stderr; echo $?
1
[root@p2w4 ~]# ls -l
total 4
-rw-r--r--. 1 root root  0 Jun 23 20:16 stderr
-rw-r--r--. 1 root root 23 Jun 23 20:16 stdout
[root@p2w4 ~]# cat stdout 
Unknown argument: lala
[root@p2w4 ~]# cat stderr
[root@p2w4 ~]# 

This issue likely affects all versions of maxctrl since its introduction as a replacement to maxadmin.


Generated at Thu Feb 08 04:26:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.