all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api] d/maintscripts: prevent aborting on errors in some commands
Date: Fri, 31 Mar 2023 13:27:47 +0200	[thread overview]
Message-ID: <20230331112747.26973-1-s.ivanov@proxmox.com> (raw)

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@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@-' being masked as
well, and still a reload of 'postfix@-' 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





             reply	other threads:[~2023-03-31 11:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31 11:27 Stoiko Ivanov [this message]
2023-06-02  8:23 ` [pmg-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230331112747.26973-1-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal