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

service.status is broken under FreeBSD #26062

Closed
silenius opened this issue Aug 6, 2015 · 8 comments
Closed

service.status is broken under FreeBSD #26062

silenius opened this issue Aug 6, 2015 · 8 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior Duplicate Duplicate of another issue or PR - will be closed Execution-Module P2 Priority 2 Platform Relates to OS, containers, platform-based utilities like FS, system based apps
Milestone

Comments

@silenius
Copy link
Contributor

silenius commented Aug 6, 2015

Hello,

I think there is an issue with the service module under FreeBSD.

If PostgreSQL is not running on sandbox and that I execute (on the master):

salt sandbox service.status postgresql

it works as expected, it returns (on the master):

sandbox:
    False

However in the sandbox logs (the minion) the command returns with an ERROR:

2015-08-06 09:51:14,364 [salt.loaded.int.module.cmdmod            ][INFO    ][59556] Executing command '/usr/sbin/service postgresql onestatus' in directory '/'
2015-08-06 09:51:14,462 [salt.loaded.int.module.cmdmod            ][ERROR   ][59556] Command '/usr/sbin/service postgresql onestatus' failed with return code: 1
2015-08-06 09:51:14,462 [salt.loaded.int.module.cmdmod            ][ERROR   ][59556] output: pg_ctl: no server running

The problem is that /usr/sbin/service exits 0 only if the service is running and >0 otherwise:

root@sandbox:~ # service postgresql onestatus ; echo $?
pg_ctl: no server running
1
root@sandbox:~ # service postgresql onestart
LOG:  could not create IPv6 socket: Address family not supported by protocol family
LOG:  redirecting log output to logging collector process
HINT:  Future log output will appear in directory "pg_log".
root@sandbox:~ # service postgresql onestatus ; echo $?
pg_ctl: server is running (PID: 60256)
/usr/local/bin/postgres "-D" "/usr/local/pgsql/data"
0

I guess that some Salt code is checking for the exit status of the command and threats != 0 as an error ...

(Note that it breaks the service state too, it turns in an infinite loop)

@silenius
Copy link
Contributor Author

silenius commented Aug 6, 2015

it seems that replacing:

return not __salt__['cmd.retcode'](cmd, python_shell=False)

with:

return not __salt__['cmd.retcode'](cmd, python_shell=False, ignore_retcode=True)

in the status function of modules/freebsdservice.py fixes the problem, although I'm not sure if that's a proper solution ..

@silenius
Copy link
Contributor Author

silenius commented Aug 6, 2015

Also, maybe related to #24783

@jfindlay jfindlay added Execution-Module Bug broken, incorrect, or confusing behavior P2 Priority 2 Platform Relates to OS, containers, platform-based utilities like FS, system based apps labels Aug 6, 2015
@jfindlay jfindlay added this to the Approved milestone Aug 6, 2015
@jfindlay
Copy link
Contributor

jfindlay commented Aug 6, 2015

@silenius, thanks for the report. See also #18510.

@JaseFace
Copy link
Contributor

JaseFace commented Aug 7, 2015

Check out #23435 also, might want to merge any info into there.

@jfindlay jfindlay added the Duplicate Duplicate of another issue or PR - will be closed label Aug 10, 2015
@jfindlay
Copy link
Contributor

Thanks @JaseFace. I forgot about that one. This looks like a duplicate of #23435.

abednarik added a commit to abednarik/salt-elk-demo that referenced this issue May 8, 2016
There is a current bug in salt freebsd service. Please see [this](saltstack/salt#26062).
@abednarik
Copy link
Contributor

Hi @silenius

I made a Pr in order help fixing this. Check this if you have time.

Thanks

@terminalmage
Copy link
Contributor

I'm not sure how this was ever "broken". It was returning the correct result. At worst it was just logging spurious errors.

@terminalmage
Copy link
Contributor

The spurious logging is removed by #33294.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Duplicate Duplicate of another issue or PR - will be closed Execution-Module P2 Priority 2 Platform Relates to OS, containers, platform-based utilities like FS, system based apps
Projects
None yet
Development

No branches or pull requests

5 participants