Skip to content

Commit

Permalink
Merge pull request #2360 from reubenmiller/fix-tedge-agent-packaging
Browse files Browse the repository at this point in the history
fix: prevent tedge-agent service stoppage when upgrading from tedge_agent
  • Loading branch information
reubenmiller authored Oct 23, 2023
2 parents e9dd11d + e6a8935 commit ec7786c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
10 changes: 6 additions & 4 deletions configuration/package_manifests/nfpm.tedge-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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



Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions configuration/package_scripts/tedge-agent/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -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#
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

1 comment on commit ec7786c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
321 0 3 321 100 51m57.121s

Please sign in to comment.