goss
goss copied to clipboard
ps output is not trimmed before checking for running process
Describe the bug Goss doesn't trim the output of ps command which can cause false alarm.
How To Reproduce
root@sp1:~# ps auxww | grep ngcp-fax
faxserv+ 1539901 0.1 2.9 126932 90308 ? Ss 09:54 0:02 ngcp-faxserver --cfg-file /etc/ngcp-faxserver/faxserver.conf
faxserv+ 1539959 0.0 2.2 82880 69800 ? S 09:54 0:00 ngcp-faxserver --cfg-file /etc/ngcp-faxserver/faxserver.conf
root@sp1:~#
root@sp1:~# ps -p 1539901 -o comm
COMMAND
ngcp-faxserver
root@sp1:~#
root@sp1:~# ps -p 1539901 -o comm | tail -1| hexdump -C
00000000 6e 67 63 70 2d 66 61 78 73 65 72 76 65 72 20 0a |ngcp-faxserver .|
00000010
root@sp1:~#
#### Steps to reproduce:
root@sp1:~# cat /tmp/failure.yaml
process:
ngcp-faxserver:
running: true
root@sp1:~# goss -g /tmp/failure.yaml validate
F
Failures/Skipped:
Process: ngcp-faxserver: running:
Expected
<bool>: false
to equal
<bool>: true
Total Duration: 0.004s
Count: 1, Failed: 1, Skipped: 0
root@sp1:~#
root@sp1:~# cat /tmp/workaround.yaml
process:
"ngcp-faxserver ":
running: true
root@sp1:~# goss -g /tmp/workaround.yaml validate
.
Total Duration: 0.004s
Count: 1, Failed: 0, Skipped: 0
root@sp1:~#
Expected Behavior Goss should trim ps output befome matching it to the value from YAML file.
Actual Behavior Goss is not removing trailing space from ps output:
00000000 6e 67 63 70 2d 66 61 78 73 65 72 76 65 72 20 0a |ngcp-faxserver .| ........................................................................................................................ ^
Environment:
- Version of goss: v0.3.14
- OS/Distribution version (if applicable): Debian 11 (bullseye)
This specific daemon sets the process-name via perl's $0 assignment, which includes arguments in there. As on Linux the comm limit is 15 characters, the space is shown but not the subsequent arguments.
I'm not convinced this is a problem in goss, as trimming on space could make it stop matching on other things, which looks like a breaking change.
Thank you for bringing this to my attention. Updated doc to avoid this issue in the future cat -E /proc/<PID>/comm will show whitespace.