From f570da3d5775d17d0e89062929a2b7958c2661e2 Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Fri, 22 Mar 2024 15:49:01 +0000 Subject: [PATCH] Skip service_resume if already enabled Repeatedly calling service_resume for a service that is already enabled can lead to unintended consequences. This adds a check to only resume a serice if it is not enabled. Related-Bug: #2058505 --- charmhelpers/core/host.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/charmhelpers/core/host.py b/charmhelpers/core/host.py index 70dde6a53..6a91e9ac9 100644 --- a/charmhelpers/core/host.py +++ b/charmhelpers/core/host.py @@ -253,6 +253,11 @@ def service_resume(service_name, init_dir="/etc/init", parameters to the init system's commandline. kwargs are ignored for systemd enabled systems. """ + if service('is-enabled', service_name): + log('service {} already enabled - skipping resume'. + format(service_name), level=INFO) + return + upstart_file = os.path.join(init_dir, "{}.conf".format(service_name)) sysv_file = os.path.join(initd_dir, service_name) if init_is_systemd(service_name=service_name):