From 33cc162f265d49d63de8b642340ce6591935bda2 Mon Sep 17 00:00:00 2001 From: Florent Carli Date: Sun, 27 Sep 2026 11:55:11 +0200 Subject: [PATCH] pacemaker: write preferred_host as its own constraint crm resource move names its constraint cli-prefer-, which looks like a manual move and is removed by crm resource clear. Write seapath-preferred- with the same infinite score instead. Signed-off-by: Florent Carli --- tests/test_pacemaker.py | 12 ++++++++++-- vm_manager/helpers/pacemaker.py | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/test_pacemaker.py b/tests/test_pacemaker.py index b85eb9f..4bd4071 100644 --- a/tests/test_pacemaker.py +++ b/tests/test_pacemaker.py @@ -313,9 +313,17 @@ def test_pin_location_names_the_constraint(self, p, crm): "hyp1", ] - def test_default_location_moves_the_resource(self, p, crm): + def test_default_location_names_the_constraint(self, p, crm): p.default_location("hyp1") - assert crm.command == ["crm", "resource", "move", RESOURCE, "hyp1"] + assert crm.command == [ + "crm", + "configure", + "location", + "seapath-preferred-vm1", + RESOURCE, + "inf:", + "hyp1", + ] class TestAddColocation: diff --git a/vm_manager/helpers/pacemaker.py b/vm_manager/helpers/pacemaker.py index 87e92f4..70e8589 100644 --- a/vm_manager/helpers/pacemaker.py +++ b/vm_manager/helpers/pacemaker.py @@ -346,12 +346,19 @@ def default_location(self, node): Set the VM default location. The VM will be deployed on the given node unless the node is up. + + Written as a constraint of its own rather than with + `crm resource move`, whose `cli-prefer-` constraint is + indistinguishable from a manual move and is removed by + `crm resource clear`. """ args = [ "crm", - "resource", - "move", + "configure", + "location", + f"seapath-preferred-{self._resource}", self._resource, + "inf:", node, ]