[pve-devel] [PATCH cluster] ensure problematic ha service is stopped during update

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Dec 7 15:10:02 CET 2017


Add a postinst file which stops, if running, the ha service before it
configures pve-cluster and starts them again, if enabled.
Do this only if the version installed before the upgrade is <= 2.0-3

dpkg-query has Version and Config-Version

Version is at this time the new unpacked version already, so we need
to check both to catch all cases.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

 debian/pve-cluster.postinst | 46 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 debian/pve-cluster.postinst

diff --git a/debian/pve-cluster.postinst b/debian/pve-cluster.postinst
new file mode 100644
index 0000000..b894e87
--- /dev/null
+++ b/debian/pve-cluster.postinst
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# abort if any command returns an error value
+set -e
+
+cp /var/lib/dpkg/status /var/lib/dpkg/status.bak
+
+# handle problem with ha-manager <= 2.0-3 which cannot handle a pmxcfs
+# restart correctly
+# TODO: remove in PVE 6.0
+ha_version=$(dpkg-query --showformat='${Version}' --show pve-ha-manager)
+hacfg_version=$(dpkg-query --showformat='${Config-Version}' --show pve-ha-manager)
+
+function handlehaservice {
+  if test -z "$1"; then
+    # no old version, nothing to do
+    true
+  else
+    if dpkg --compare-versions "$ha_version" '<=' '2.0-3' || dpkg --compare-versions "$hacfg_version" '<=' '2.0-3'; then
+      if systemctl --quiet "$2" "pve-ha-crm.service"; then
+        systemctl "$3" "pve-ha-crm.service"
+      fi
+      if systemctl --quiet "$2" "pve-ha-lrm.service"; then
+        systemctl "$3" "pve-ha-lrm.service"
+      fi
+    fi
+  fi
+}
+
+
+case "$1" in
+  configure)
+    handlehaservice "$2" 'is-active' 'stop'
+    ;;
+
+esac
+
+#DEBHELPER#
+
+case "$1" in
+  configure)
+    handlehaservice "$2" 'is-enabled' 'start'
+    ;;
+
+esac
+
-- 
2.11.0





More information about the pve-devel mailing list