juju / charm-helpers

Apache License 2.0
18 stars 127 forks source link

Skip service_enable if already enabled #886

Closed brianphaley closed 4 months ago

brianphaley commented 5 months ago

Repeatedly calling service_enable for a service that is already enabled can lead to unintended consequences. Some charms frequently call servie_resume which will call service('enable') and this adds a check to only do so of the service is not enabled.

Related-Bug: #2058505 (cherry picked from commit a3345005e597f098909b7c12dfee630a366ce0f6)

fnordahl commented 4 months ago

Thank you for putting forward multiple options to solve this, I chose to merge #890 which would allow us to consider this PR in a uniform manner along with the other backports. Would you be able to rebase?

brianphaley commented 4 months ago

Sure, I can rebase this one. I threw the squashed option because i wanted them both tested together, but github had other plans. The cherry-pick for 890 at least fixed the unit test failure locally.