sensu / sensu-omnibus

Build full-stack platform-specific Sensu packages
12 stars 16 forks source link

systemd implementation does not honor service-specific defaults #225

Closed cwjohnston closed 6 years ago

cwjohnston commented 7 years ago

The following issue was brought to my attention by @paulczar via #monitoring_love on HangOps Slack organization.

Expected Behavior

All Sensu service management scripts, whether sysv or systemd, should honor environment variables set in /etc/default/sensu and the service-specific defaults file, e.g. /etc/default/sensu-server in the case of sensu-server service.

Current behavior

sysv init script checks for the existence of both /etc/default/sensu and service-specific default files, sourcing them when present. After sourcing these files, sysv script eventually calls /opt/sensu/bin/sensu-service with arguments to start the desired Sensu service.

systemd unit specifies no environment files, calls /opt/sensu/bin/sensu-service directly. /opt/sensu/bin/sensu-service sources /etc/default/sensu, if it exists, but does not attempt to source service-specific default files.

Possible solution

Move service-specific default logic in sysv init script into /opt/sensu/bin/sensu-service wrapper script.

Additionally, @paulczar writes:

if you used ETC_DIR=${ETC_DIR:-"/etc"} in that service script ... and did the same with all the other variables you set at the top ( and set a variable for DEFAULTs_DIR ) then I'd be able to change any of those settings in my unit file by setting env vars .. which would be useful

paulczar commented 7 years ago

:+1: I'm now working around this with a dirty sed ( well actually ansible's lineinfile ) to the /opt/sensu/bin/sensu-service script to fix the calls to be to /etc/defaut/sensu-<service_name> but would love to see a fix and new package so I don't have to commit such atrocities.

I can help work on this if need be, the changes should be fairly straight forward.

paulczar commented 7 years ago

Although tbh I struggle to understand the value of /opt/sensu/bin/sensu-service I get it's probably useful for making it easier to deal with multiple init systems, but from a ubuntu xenial / systemd perspective I'm not sure I see anything much in there you couldn't deal with calling /opt/sensu/bin/sensu-server ..... from a systemd unit file.

grepory commented 7 years ago

@portertech ptal

portertech commented 7 years ago

@cwjohnston let's look at this together, tomorrow.