From 04742c1d539ca3608e758c1abefb5d16c7b98bad Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Fri, 20 Oct 2023 18:19:15 +0200 Subject: [PATCH 1/2] include updating the tedge agent in the self update system tests Signed-off-by: Reuben Miller --- .../tests/cumulocity/self-update/tedge_self_update.robot | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/RobotFramework/tests/cumulocity/self-update/tedge_self_update.robot b/tests/RobotFramework/tests/cumulocity/self-update/tedge_self_update.robot index 53f24e5803a..1a77afc7480 100644 --- a/tests/RobotFramework/tests/cumulocity/self-update/tedge_self_update.robot +++ b/tests/RobotFramework/tests/cumulocity/self-update/tedge_self_update.robot @@ -28,10 +28,10 @@ Update tedge version from previous using Cumulocity # Install desired version Create Local Repository - [Documentation] tedge-agent causes a problem where the operation is stuck in EXECUTING state - ${OPERATION}= Install Software tedge,${NEW_VERSION} tedge-mapper,${NEW_VERSION} tedge-watchdog,${NEW_VERSION} tedge-log-plugin,${NEW_VERSION} c8y-configuration-plugin,${NEW_VERSION} tedge-apt-plugin,${NEW_VERSION} + ${OPERATION}= Install Software tedge,${NEW_VERSION} tedge-mapper,${NEW_VERSION} tedge-agent,${NEW_VERSION} tedge-watchdog,${NEW_VERSION} tedge-log-plugin,${NEW_VERSION} c8y-configuration-plugin,${NEW_VERSION} tedge-apt-plugin,${NEW_VERSION} Operation Should Be SUCCESSFUL ${OPERATION} timeout=180 - Device Should Have Installed Software tedge,${NEW_VERSION_ESCAPED}::apt tedge-mapper,${NEW_VERSION_ESCAPED}::apt tedge-watchdog,${NEW_VERSION_ESCAPED}::apt c8y-configuration-plugin,${NEW_VERSION_ESCAPED}::apt tedge-log-plugin,${NEW_VERSION_ESCAPED}::apt tedge-apt-plugin,${NEW_VERSION_ESCAPED}::apt + + Device Should Have Installed Software tedge,${NEW_VERSION_ESCAPED}::apt tedge-mapper,${NEW_VERSION_ESCAPED}::apt tedge-agent,${NEW_VERSION_ESCAPED}::apt tedge-watchdog,${NEW_VERSION_ESCAPED}::apt c8y-configuration-plugin,${NEW_VERSION_ESCAPED}::apt tedge-log-plugin,${NEW_VERSION_ESCAPED}::apt tedge-apt-plugin,${NEW_VERSION_ESCAPED}::apt # Check if services are still stopped and disabled ${OUTPUT} Execute Command systemctl is-active tedge-mapper-az || exit 1 exp_exit_code=1 strip=True From e6a8935f1203985569b363b9c073b7925dee5103 Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Fri, 20 Oct 2023 18:18:00 +0200 Subject: [PATCH 2/2] fix(packaging): prevent prerm from stopping the tedge-agent service when being replaced during an OTA Debian maintainer scripts run the prerm script if the incoming package uses conflicts or breaks. This results in the tedge-agent being stopped midway through an over the air update. Signed-off-by: Reuben Miller --- configuration/package_manifests/nfpm.tedge-agent.yaml | 10 ++++++---- .../_generated/tedge-agent/apk/postinst | 3 +++ .../_generated/tedge-agent/deb/postinst | 3 +++ .../_generated/tedge-agent/rpm/postinst | 3 +++ configuration/package_scripts/tedge-agent/postinst | 3 +++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/configuration/package_manifests/nfpm.tedge-agent.yaml b/configuration/package_manifests/nfpm.tedge-agent.yaml index feab780b9f2..15a1be58ef1 100644 --- a/configuration/package_manifests/nfpm.tedge-agent.yaml +++ b/configuration/package_manifests/nfpm.tedge-agent.yaml @@ -20,16 +20,18 @@ replaces: - tedge_agent provides: - tedge_agent -conflicts: - - tedge_agent (<= 0.8.1) + +# WARNING: Don't use conflicts or breaks as this causes the old packages prerm script to be executed +# which stops the tedge-agent thus causing the OTA to be stuck in EXECUTING. +# One disadvantage is that the tedge_agent package needs to be manually removed after upgrading. The new +# tedge-agent package removes the legacy tedge_agent.prerm script to prevent the new service from being +# stopped as well. deb: fields: Vcs-Browser: ${CI_PROJECT_URL} Vcs-Git: ${CI_PROJECT_URL} compression: xz - breaks: - - tedge_agent (<= 0.8.1) contents: # service definitions diff --git a/configuration/package_scripts/_generated/tedge-agent/apk/postinst b/configuration/package_scripts/_generated/tedge-agent/apk/postinst index a4b07928b19..838b156aea3 100644 --- a/configuration/package_scripts/_generated/tedge-agent/apk/postinst +++ b/configuration/package_scripts/_generated/tedge-agent/apk/postinst @@ -5,5 +5,8 @@ set -e # Prevent purge from deleting files related to the package rm -f /var/lib/dpkg/info/tedge_agent.postrm +# Remove older prerm maintainer scripts which would stop the tedge-agent service during an OTA +rm -f /var/lib/dpkg/info/tedge_agent.prerm + diff --git a/configuration/package_scripts/_generated/tedge-agent/deb/postinst b/configuration/package_scripts/_generated/tedge-agent/deb/postinst index d1fa8c6ad8f..39cf1d51b1b 100755 --- a/configuration/package_scripts/_generated/tedge-agent/deb/postinst +++ b/configuration/package_scripts/_generated/tedge-agent/deb/postinst @@ -5,6 +5,9 @@ set -e # Prevent purge from deleting files related to the package rm -f /var/lib/dpkg/info/tedge_agent.postrm +# Remove older prerm maintainer scripts which would stop the tedge-agent service during an OTA +rm -f /var/lib/dpkg/info/tedge_agent.prerm + # Automatically added by thin-edge.io if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if deb-systemd-helper debian-installed tedge-agent.service; then diff --git a/configuration/package_scripts/_generated/tedge-agent/rpm/postinst b/configuration/package_scripts/_generated/tedge-agent/rpm/postinst index 059178ef838..25a79dda548 100644 --- a/configuration/package_scripts/_generated/tedge-agent/rpm/postinst +++ b/configuration/package_scripts/_generated/tedge-agent/rpm/postinst @@ -5,6 +5,9 @@ set -e # Prevent purge from deleting files related to the package rm -f /var/lib/dpkg/info/tedge_agent.postrm +# Remove older prerm maintainer scripts which would stop the tedge-agent service during an OTA +rm -f /var/lib/dpkg/info/tedge_agent.prerm + # Automatically added by thin-edge.io if [ $1 -eq 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then # Initial installation diff --git a/configuration/package_scripts/tedge-agent/postinst b/configuration/package_scripts/tedge-agent/postinst index 73c39a0e910..ae50630984f 100644 --- a/configuration/package_scripts/tedge-agent/postinst +++ b/configuration/package_scripts/tedge-agent/postinst @@ -5,4 +5,7 @@ set -e # Prevent purge from deleting files related to the package rm -f /var/lib/dpkg/info/tedge_agent.postrm +# Remove older prerm maintainer scripts which would stop the tedge-agent service during an OTA +rm -f /var/lib/dpkg/info/tedge_agent.prerm + #LINUXHELPER#