[pmg-devel] [PATCH pmg-api] d/maintscripts: prevent aborting on errors in some commands

Stoiko Ivanov s.ivanov at proxmox.com
Fri Mar 31 13:27:47 CEST 2023


in case something goes wrong it is often better to not leave the
packaging state broken.

failure in the commands masked by this patch are either transient
(pmgconfig sync -restart 1 failing when services are masked), or will
be noticed quite instantly (failed database or config initialization
upon first install)

the deb-systemd-invoke change was based on a quick grep in
/var/lib/dpkg/info on my system

I quickly considered masking even more errors (e.g. related to the ucf
handling) - but they don't seem to cause issues (in the past 3 years)
- and if something breaks there it is probably worth to get a report

reported in our community forum:
https://forum.proxmox.com/threads/.125088/

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
This patch should fix the issue - I considered the suggestions discussed
off-list with making the reload command not fail when the config-rewrite
issues it - but doing so in general feels wrong.
Ignoring a failure if a service is masked did not seem robust - e.g.
masking 'postfix.service' does not result in 'postfix at -' being masked as
well, and still a reload of 'postfix at -' service fails (and explicitly
listing this one edge-case felt a bit brittle)
Finally not erroring out in `pmgconfig sync -restart 1` felt off as it's
the direct entry point for the user - and masking an error should be the
caller's responsibility

Reproduced the issue from the forum with a 7.2 installation and masking
all services as in the upgrade guide[0] before upgrading and with this
patch the upgrade does not result in a broken dpkg state anymore

[0] https://pmg.proxmox.com/wiki/index.php/Upgrade_from_6.x_to_7.0

 debian/postinst | 6 +++---
 debian/prerm    | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/debian/postinst b/debian/postinst
index 690d10d..d4d434a 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -89,11 +89,11 @@ case "$1" in
 
         if test ! -e /proxmox_install_mode ; then
 
-            pmgconfig init
-            pmgdb init
+            pmgconfig init || true
+            pmgdb init || true
 
             ucf_register_templates
-            pmgconfig sync --restart
+            pmgconfig sync --restart || true
 
             if [ -z "$2" ]; then
                 if systemctl --quiet is-active pmgpolicy.service ; then
diff --git a/debian/prerm b/debian/prerm
index 4d0ca06..f9b6f3a 100644
--- a/debian/prerm
+++ b/debian/prerm
@@ -19,7 +19,7 @@ case "$1" in
 esac
 
 if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
-    deb-systemd-invoke stop pmgproxy.service pmgdaemon.service >/dev/null
+    deb-systemd-invoke stop pmgproxy.service pmgdaemon.service >/dev/null || true
 fi
 
 # dh_installdeb will replace this with shell code automatically
-- 
2.30.2





More information about the pmg-devel mailing list