diff options
| author | Stefan Hanreich <s.hanreich@proxmox.com> | 2024-11-19 14:30:56 +0100 |
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2024-11-19 16:41:33 +0100 |
| commit | d0628dfddf6ad0fe0303870f5fe9e8b16d548a14 (patch) | |
| tree | 74cd7a752fedd7109c450cd0c58ad84c3aca9332 | |
| parent | cbc70c81b9a2647a20903b27cabb14c1d6dc6d76 (diff) | |
debian: migrate legacy mac/ipam cache/state files
We opted for a simple copy of the legacy file to the new location,
since any other migration path would be too strenuous. The worst-case
scenario of failures with this approach is losing IPAM / MAC entries
that are created during the update window in the legacy files by nodes
that are not yet updated to the new version. Those can be fixed by a
simple start / stop of the affected VMs, triggering a rewrite of the
IPAM database.
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
[ TL: output message if files get moved and add todo-comment ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
| -rw-r--r-- | debian/libpve-network-perl.postinst | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/debian/libpve-network-perl.postinst b/debian/libpve-network-perl.postinst new file mode 100644 index 0000000..c28328d --- /dev/null +++ b/debian/libpve-network-perl.postinst @@ -0,0 +1,35 @@ +#!/bin/sh + +set -e + +migrate_ipam_db() { + LEGACY_IPAM_DB_FILE="/etc/pve/priv/ipam.db" + IPAM_DB_FILE="/etc/pve/sdn/pve-ipam-state.json" + + if test -f "$LEGACY_IPAM_DB_FILE" && test ! -f "$IPAM_DB_FILE"; then + echo "copying over existing legacy IPAM state file to new path..." + cp $LEGACY_IPAM_DB_FILE $IPAM_DB_FILE + fi +} + +migrate_mac_cache() { + LEGACY_MAC_DB_FILE="/etc/pve/priv/macs.db" + MAC_DB_FILE="/etc/pve/sdn/mac-cache.json" + + if test -f "$LEGACY_MAC_DB_FILE" && test ! -f "$MAC_DB_FILE"; then + echo "copying over existing legacy IPAM MAC-map cache file to new path..." + cp $LEGACY_MAC_DB_FILE $MAC_DB_FILE + fi +} + +case "$1" in + configure) + # TODO: remove with PVE 9+ + if dpkg --compare-versions "$2" 'lt' '0.9.9'; then + migrate_ipam_db + migrate_mac_cache + fi + ;; +esac + +exit 0 |
