From 2bc946856dbedf918d50e80ea4da80ece5ff442f Mon Sep 17 00:00:00 2001 From: Palash Gandhi Date: Mon, 18 Sep 2023 16:58:38 -0700 Subject: [PATCH] DLPX-84565 telegraf.service restarts after upgrade when it should be masked PR URL: https://www.github.com/delphix/appliance-build/pull/739 --- upgrade/upgrade-scripts/common.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/upgrade/upgrade-scripts/common.sh b/upgrade/upgrade-scripts/common.sh index c52058eb..53de88ac 100644 --- a/upgrade/upgrade-scripts/common.sh +++ b/upgrade/upgrade-scripts/common.sh @@ -381,7 +381,7 @@ function mask_service() { chroot "/var/lib/machines/$container" systemctl mask "$svc" || die "failed to mask '$svc' in container '$container'" else - systemctl mask "$svc" || die "failed to mask '$svc'" + systemctl mask --now "$svc" || die "failed to mask '$svc'" fi } @@ -417,6 +417,18 @@ function is_svc_new_or_masked_or_disabled() { function fix_and_migrate_services() { local container="$1" + # + # telegraf was introduced in 6.0.15.0. If an engine was upgraded from a version <6.0.15.0 to + # >=6.0.15.0, the telegraf service is running because of it's postinst script. While fresh + # installs of engines >=6.0.15.0 ensured that the telegraf.service was disabled, the upgrade path + # did not. Since this function is first used to create an upgrade container and uses the state of + # services on the running system as the source of truth, it is the right place to disable the + # service on the engine if it is running. + # + if [[ -n "$container" ]] && [[ "$(systemctl is-enabled telegraf.service)" == enabled ]]; then + systemctl disable telegraf.service + fi + # # This function must be called from outside an upgrade container as it # uses the state of the services on the running system as the source of @@ -483,5 +495,6 @@ function fix_and_migrate_services() { snmpd.service systemd-timesyncd.service td-agent.service + telegraf.service EOF }