canonical / operator-libs-linux

Linux helper libraries for the operator framework
Apache License 2.0
11 stars 39 forks source link

Enable systemd service methods to accept multiple args #106

Closed NucciTheBoss closed 1 year ago

NucciTheBoss commented 1 year ago

Hello - this pull request extends the service methods in the systemd charm library to now accept multiple arguments. I made this change so that when charm authors need to pass extra parameters to systemctl, they do not need to directly call the private _systemctl method and can instead pass the extra arguments to via the public service_* methods.

For example, say you have a service that takes several seconds to start. Using service_start(...) in its currently implementation will cause Python to block until systemctl returns an exit code (Popen.wait()). This is inconvenient especially if you have a service that could take 30+ seconds to start. With the implementation this pull request proposes, you can pass the --no-block option to service_start(...) and let the charm continue on its way while the systemd starts the service in the background.

Notes

NucciTheBoss commented 1 year ago

BAH - integration tests need to be updated since service_start(...), service_stop(...), etc no longer return boolean values.

NucciTheBoss commented 1 year ago

Latest integration test failure seems to be a timeout failure with the snap charm library. Looks like it times out waiting for LXD to stop.

NucciTheBoss commented 1 year ago

Looks good to me! Just one nit comment, but approving.

Awesome, I responded to your review comment. Let me bump the LIBPATCH version of the systemd charm library and we should be good to merge!