Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 674836

Summary: dev-db/postgresql-10.6: init script "postgresql-10" has weird output for "status"
Product: Gentoo Linux Reporter: David Klaftenegger <davidweb>
Component: Current packagesAssignee: PgSQL Bugs <pgsql-bugs>
Status: RESOLVED INVALID    
Severity: normal CC: hydrapolic
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description David Klaftenegger 2019-01-07 23:25:05 UTC
Hi,

when scripting around in my system I discovered ansible's openrc module is not correctly discovering the status of postgresql-10.
To check the current status of the service, ansible is looking for the string "started" in the output of

rc-service postgresql-10 status

The currently observed output is:
# rc-service postgresql-10 status
 * Checking PostgreSQL 10 status ...
pg_ctl: server is running (PID: 31511)
/usr/lib64/postgresql-10/bin/postgres "-D" "/etc/postgresql-10" "--data-directory=/srv/db/postgresql/10/data" "--unix-socket-directories="      [ ok ]

The expected output is:

# rc-service postgresql-10 status
 * status: started

Note that I could cause weird interactions between what tools expect and the output by giving a strange name to my data directory.



If this is not considered a bug, could you please explain how a tool should correctly check for service status with openrc, so I can file an appropriate bug with ansible?
Comment 1 Aaron W. Swenson gentoo-dev 2019-01-11 20:10:01 UTC
As OpenRC passes along the exit code of the last command run in the init script, the Ansible module should be checking that exit code rather than grepping for a keyword. Further, there are standards[1] for the exit codes, whereas there are none for textual phrases -- at least, not that I could find.

Alternatively, maybe the Ansible module could make use of the output from rc-status. But, there doesn't appear to be any promises from upstream that the output format will never change.

The init script makes use of pg_ctl which has additional checks to verify that the server we're getting information on is the server we think it is, and not some imposter. The pg_ctl program itself is responsible for the output, and for setting the exit code. This init script is not alone in including additional information in the status message.

In short, I think the behavior of the postgresql-XX init scripts are correct and normal; Ansible is being weird.

[1]: http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
Comment 2 David Klaftenegger 2019-01-11 22:54:53 UTC
Thank you. Reported at https://github.com/ansible/ansible/issues/50822