Blame SOURCES/bz1507399-01-Make-resource-update-idempotent-with-remote-node.patch

1c1da3
From a2d864535fc819c8b9c599aeccf1128716d56b15 Mon Sep 17 00:00:00 2001
1c1da3
From: Bruno Travouillon <devel@travouillon.fr>
1c1da3
Date: Fri, 29 Sep 2017 20:22:16 +0200
1c1da3
Subject: [PATCH] Make resource update idempotent with remote-node
1c1da3
1c1da3
If the remote-node name argument is already defined for the resource,
1c1da3
do not deal with guest change.
1c1da3
1c1da3
Fix issue #145.
1c1da3
---
1c1da3
 pcs/resource.py                      | 15 ++++++++++-----
1c1da3
 pcs/test/test_cluster_pcmk_remote.py | 10 ++++++++++
1c1da3
 2 files changed, 20 insertions(+), 5 deletions(-)
1c1da3
1c1da3
diff --git a/pcs/resource.py b/pcs/resource.py
1c1da3
index 818cb5b..39f6fc2 100644
1c1da3
--- a/pcs/resource.py
1c1da3
+++ b/pcs/resource.py
1c1da3
@@ -723,11 +723,6 @@ def resource_update(res_id,args, deal_with_guest_change=True):
1c1da3
 
1c1da3
 # Extract operation arguments
1c1da3
     ra_values, op_values, meta_values = parse_resource_options(args)
1c1da3
-    if deal_with_guest_change:
1c1da3
-        _detect_guest_change(
1c1da3
-            prepare_options(meta_values),
1c1da3
-            "--force" in utils.pcs_options,
1c1da3
-        )
1c1da3
 
1c1da3
     wait = False
1c1da3
     wait_timeout = None
1c1da3
@@ -811,6 +806,16 @@ def resource_update(res_id,args, deal_with_guest_change=True):
1c1da3
             instance_attributes.appendChild(ia)
1c1da3
 
1c1da3
     remote_node_name = utils.dom_get_resource_remote_node_name(resource)
1c1da3
+
1c1da3
+    if remote_node_name == guest_node.get_guest_option_value(prepare_options(meta_values)):
1c1da3
+        deal_with_guest_change = False
1c1da3
+
1c1da3
+    if deal_with_guest_change:
1c1da3
+        _detect_guest_change(
1c1da3
+            prepare_options(meta_values),
1c1da3
+            "--force" in utils.pcs_options,
1c1da3
+        )
1c1da3
+
1c1da3
     utils.dom_update_meta_attr(
1c1da3
         resource,
1c1da3
         utils.convert_args_to_tuples(meta_values)
1c1da3
diff --git a/pcs/test/test_cluster_pcmk_remote.py b/pcs/test/test_cluster_pcmk_remote.py
1c1da3
index 0db4a5c..aa6a215 100644
1c1da3
--- a/pcs/test/test_cluster_pcmk_remote.py
1c1da3
+++ b/pcs/test/test_cluster_pcmk_remote.py
1c1da3
@@ -291,6 +291,16 @@ class NodeAddGuest(ResourceTest):
1c1da3
             output=fixture_nolive_add_report
1c1da3
         )
1c1da3
 
1c1da3
+    def test_success_when_guest_node_matches_with_existing_guest(self):
1c1da3
+        self.create_resource()
1c1da3
+        self.assert_pcs_success(
1c1da3
+            "cluster node add-guest node-host G",
1c1da3
+            fixture_nolive_add_report
1c1da3
+        )
1c1da3
+        self.assert_pcs_success(
1c1da3
+            "resource update G meta remote-node=node-host",
1c1da3
+        )
1c1da3
+
1c1da3
     def test_success_with_options(self):
1c1da3
         self.create_resource()
1c1da3
         self.assert_effect(
1c1da3
-- 
1c1da3
1.8.3.1
1c1da3