Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ps output is not trimmed before checking for running process #762

Closed
taurus-forever opened this issue May 24, 2022 · 2 comments · Fixed by #814
Closed

ps output is not trimmed before checking for running process #762

taurus-forever opened this issue May 24, 2022 · 2 comments · Fixed by #814
Labels

Comments

@taurus-forever
Copy link

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)
sipwise-jenkins pushed a commit to sipwise/system-tests that referenced this issue May 24, 2022
Goss doesn't trim the trailing space at the end of process name.
It is a workaround for the issue reported upstream as:
> goss-org/goss#762
It can be reverted as soon as issue is fixed in goss.

Change-Id: Ie3d7e2b3470aed9aa3c5ee3743d950237919dbde
@guillemj
Copy link
Contributor

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.

@aelsabbahy aelsabbahy mentioned this issue Jun 25, 2023
3 tasks
@aelsabbahy
Copy link
Member

aelsabbahy commented Jul 19, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants