From 764f74bb363613c63c3757637267bf37ee2381a0 Mon Sep 17 00:00:00 2001
From: Ivan Devat <idevat@redhat.com>
Date: Wed, 7 Jun 2017 14:36:05 +0200
Subject: [PATCH] squash bz1459503 OSP workarounds not compatible wi
reuse existing pcmk authkey during setup
show only warn if `resource create` creates remote
---
pcs/cluster.py | 10 +++++++++-
pcs/lib/commands/resource.py | 6 ++++--
pcs/test/cib_resource/test_create.py | 13 ++++++-------
pcs/test/test_resource.py | 24 ++++++++++++------------
4 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/pcs/cluster.py b/pcs/cluster.py
index d896b0c..16eb0c5 100644
--- a/pcs/cluster.py
+++ b/pcs/cluster.py
@@ -452,13 +452,21 @@ def cluster_setup(argv):
print("Destroying cluster on nodes: {0}...".format(
", ".join(primary_addr_list)
))
+
+ try:
+ pcmk_authkey_content = (
+ open(settings.pacemaker_authkey_file, "rb").read()
+ )
+ except EnvironmentError as e:
+ pcmk_authkey_content = generate_key()
+
destroy_cluster(primary_addr_list)
print()
try:
file_definitions = {}
file_definitions.update(
- node_communication_format.pcmk_authkey_file(generate_key())
+ node_communication_format.pcmk_authkey_file(pcmk_authkey_content)
)
if modifiers["encryption"] == "1":
file_definitions.update(
diff --git a/pcs/lib/commands/resource.py b/pcs/lib/commands/resource.py
index 0c5f682..0c4d6fc 100644
--- a/pcs/lib/commands/resource.py
+++ b/pcs/lib/commands/resource.py
@@ -69,7 +69,8 @@ def _validate_remote_connection(
report_list.append(
reports.get_problem_creator(
report_codes.FORCE_NOT_SUITABLE_COMMAND,
- allow_not_suitable_command
+ is_forced=True,
+ # allow_not_suitable_command
)(reports.use_command_node_add_remote)
)
@@ -99,7 +100,8 @@ def _validate_guest_change(
report_list.append(
reports.get_problem_creator(
report_codes.FORCE_NOT_SUITABLE_COMMAND,
- allow_not_suitable_command
+ is_forced=True
+ # allow_not_suitable_command
)(create_report)
)
diff --git a/pcs/test/cib_resource/test_create.py b/pcs/test/cib_resource/test_create.py
index 045ce68..afd7d0a 100644
--- a/pcs/test/cib_resource/test_create.py
+++ b/pcs/test/cib_resource/test_create.py
@@ -1463,11 +1463,10 @@ class FailOrWarnGroup(ResourceTest):
)
def test_fail_when_on_pacemaker_remote_attempt(self):
- self.assert_pcs_fail(
+ self.assert_pcs_success(
"resource create R2 ocf:pacemaker:remote",
- "Error: this command is not sufficient for creating a remote"
- " connection, use 'pcs cluster node add-remote'"
- ", use --force to override\n"
+ "Warning: this command is not sufficient for creating a remote"
+ " connection, use 'pcs cluster node add-remote'\n"
)
def test_warn_when_on_pacemaker_remote_attempt(self):
@@ -1567,10 +1566,10 @@ class FailOrWarnGroup(ResourceTest):
)
def test_fail_when_on_pacemaker_remote_guest_attempt(self):
- self.assert_pcs_fail(
+ self.assert_pcs_success(
"resource create R2 ocf:heartbeat:Dummy meta remote-node=HOST",
- "Error: this command is not sufficient for creating a guest node,"
- " use 'pcs cluster node add-guest', use --force to override\n"
+ "Warning: this command is not sufficient for creating a guest node,"
+ " use 'pcs cluster node add-guest'\n"
)
def test_warn_when_on_pacemaker_remote_guest_attempt(self):
diff --git a/pcs/test/test_resource.py b/pcs/test/test_resource.py
index 5bc9517..9ab1dd5 100644
--- a/pcs/test/test_resource.py
+++ b/pcs/test/test_resource.py
@@ -4973,10 +4973,10 @@ class ResourceUpdateSpcialChecks(unittest.TestCase, AssertPcsMixin):
self.assert_pcs_success(
"resource create R ocf:heartbeat:Dummy",
)
- self.assert_pcs_fail(
+ self.assert_pcs_success(
"resource update R meta remote-node=HOST",
- "Error: this command is not sufficient for creating a guest node,"
- " use 'pcs cluster node add-guest', use --force to override\n"
+ "Warning: this command is not sufficient for creating a guest node,"
+ " use 'pcs cluster node add-guest'\n"
)
def test_update_warn_on_pacemaker_guest_attempt(self):
self.assert_pcs_success(
@@ -4995,10 +4995,10 @@ class ResourceUpdateSpcialChecks(unittest.TestCase, AssertPcsMixin):
"Warning: this command is not sufficient for creating a guest node,"
" use 'pcs cluster node add-guest'\n"
)
- self.assert_pcs_fail(
+ self.assert_pcs_success(
"resource update R meta remote-node=",
- "Error: this command is not sufficient for removing a guest node,"
- " use 'pcs cluster node remove-guest', use --force to override\n"
+ "Warning: this command is not sufficient for removing a guest node,"
+ " use 'pcs cluster node remove-guest'\n"
)
def test_update_warn_on_pacemaker_guest_attempt_remove(self):
@@ -5019,10 +5019,10 @@ class ResourceUpdateSpcialChecks(unittest.TestCase, AssertPcsMixin):
self.assert_pcs_success(
"resource create R ocf:heartbeat:Dummy",
)
- self.assert_pcs_fail(
+ self.assert_pcs_success(
"resource meta R remote-node=HOST",
- "Error: this command is not sufficient for creating a guest node,"
- " use 'pcs cluster node add-guest', use --force to override\n"
+ "Warning: this command is not sufficient for creating a guest node,"
+ " use 'pcs cluster node add-guest'\n"
)
def test_meta_warn_on_pacemaker_guest_attempt(self):
@@ -5043,10 +5043,10 @@ class ResourceUpdateSpcialChecks(unittest.TestCase, AssertPcsMixin):
"Warning: this command is not sufficient for creating a guest node,"
" use 'pcs cluster node add-guest'\n"
)
- self.assert_pcs_fail(
+ self.assert_pcs_success(
"resource meta R remote-node=",
- "Error: this command is not sufficient for removing a guest node,"
- " use 'pcs cluster node remove-guest', use --force to override\n"
+ "Warning: this command is not sufficient for removing a guest node,"
+ " use 'pcs cluster node remove-guest'\n"
)
def test_meta_warn_on_pacemaker_guest_attempt_remove(self):
--
1.8.3.1