From 0ee67614fb4779cdbd8cf62e6b7ffe6fe51475f8 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 | 12 +++++++++++- upgrade/upgrade-scripts/execute | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/upgrade/upgrade-scripts/common.sh b/upgrade/upgrade-scripts/common.sh index c52058eb..052acaf9 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 } @@ -442,6 +442,15 @@ function fix_and_migrate_services() { fi fi + # + # Due to https://github.com/influxdata/telegraf/issues/14052, telegraf must be masked after + # packages are upgraded. The telegraf package removes /etc/systemd/system/telegraf.service thus + # reversing the `systemctl mask` operation performed before the packages are upgraded. + # + if [[ "$(systemctl is-enabled telegraf)" == enabled ]]; then + mask_service telegraf "$container" + fi + # # The services listed below are either permanently disabled or can be # dynamically modified by the application(s) running on the appliance, @@ -483,5 +492,6 @@ function fix_and_migrate_services() { snmpd.service systemd-timesyncd.service td-agent.service + telegraf.service EOF } diff --git a/upgrade/upgrade-scripts/execute b/upgrade/upgrade-scripts/execute index afc38481..08143f23 100755 --- a/upgrade/upgrade-scripts/execute +++ b/upgrade/upgrade-scripts/execute @@ -380,6 +380,15 @@ dpkg-query -Wf '${Conffiles}\n' | awk '$3 == "obsolete" {print $1}' | die "failed to reinstall package '$package'" done || die "failed to remove obsolete package configuration files" +# +# telegraf's postinst script recreates the service unit and attempts to enable the service, +# which means that the previous attempt to mask it is reversed. Due to this and DLPX-84565, +# telegraf must be masked after packages are upgraded. +# +if [[ "$(systemctl is-enabled telegraf)" == enabled ]]; then + systemctl mask --now telegraf.service +fi + # # Unmask docker, which was masked at the beginning of the upgrade due # to DLPX-77949.