From 19f3e7a325696cf33a8d85a0d4ccc8358f750f1d Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 12 Oct 2017 09:35:59 +0100 Subject: [PATCH] Allow fencing config generation before deployment. With this commit we are able to generate the fencing configuration for IPMI hosts before deployment, and thus use it as part of the initial deployment run. The reason we can generate it before hand is the following: puppet::tripleo is capable of matching its own host via https://github.com/openstack/puppet-tripleo/blob/master/manifests/fencing.pp#L73 and by doing that each node will create its own stonith device. It does so by looking at the macaddress<->IPMI table and if it detects it's own macaddress it will create the IPMI stonith device for its own hostname. Concurrent stonith resource creation from different nodes is possible in puppet-pacemaker since change I8be5d5d1a9894b0e2915459b10ea2feed703ba8e got merged. Tested as follows on a virtual vbmc environment: 1. Before deployment: $ openstack overcloud generate fencing instackenv.json --output fence.yaml 2. Deployed overcloud adding "fence.yaml" 3. Verified stonith configuration: [root@controller-0 ~]# pcs status |grep stonith stonith-fence_ipmilan-525400c36fc9 (stonith:fence_ipmilan): Started controller-0 stonith-fence_ipmilan-5254005c160d (stonith:fence_ipmilan): Started controller-2 stonith-fence_ipmilan-525400ed3293 (stonith:fence_ipmilan): Started controller-1 [root@controller-0 ~]# pcs property |grep stonith stonith-enabled: true 4. Verified the fencing of a specific node: [root@controller-0 ~]# pcs stonith fence controller-1 Node: controller-1 fenced Same test run on BM: 1. Before deployment: $ openstack overcloud generate fencing instackenv.json --output fence.yaml 2. Deployed overcloud adding "fence.yaml" 3. Verified stonith configuration: [root@controller-0 ~]# pcs status |grep stonith stonith-fence_ipmilan-1866da6126a0 (stonith:fence_ipmilan): Started overcloud-controller-0 stonith-fence_ipmilan-1866da612109 (stonith:fence_ipmilan): Started overcloud-controller-1 stonith-fence_ipmilan-1866da5faed8 (stonith:fence_ipmilan): Started overcloud-controller-2 stonith-fence_ipmilan-1866da612373 (stonith:fence_ipmilan): Started overcloud-controller-2 stonith-fence_ipmilan-1866da612295 (stonith:fence_ipmilan): Started overcloud-controller-0 [root@overcloud-controller-0 ~]# pcs property |grep stonith stonith-enabled: true 4. Verified the fencing of a specific node: [root@overcloud-controller-0 ~]# pcs stonith fence overcloud-controller-1 & ping overcloud-controller-1 [1] 168504 PING overcloud-controller-1.localdomain (172.17.0.14) 56(84) bytes of data. 64 bytes from overcloud-controller-1.localdomain (172.17.0.14): icmp_seq=1 ttl=64 time=0.139 ms 64 bytes from overcloud-controller-1.localdomain (172.17.0.14): icmp_seq=2 ttl=64 time=0.135 ms 64 bytes from overcloud-controller-1.localdomain (172.17.0.14): icmp_seq=3 ttl=64 time=0.132 ms 64 bytes from overcloud-controller-1.localdomain (172.17.0.14): icmp_seq=4 ttl=64 time=0.150 ms 64 bytes from overcloud-controller-1.localdomain (172.17.0.14): icmp_seq=5 ttl=64 time=0.161 ms Closes-Bug: #1765727 Change-Id: I41f81dc9d68bcf23e6171e35bb053a3943f50c01 --- tripleo_common/actions/parameters.py | 8 +++++--- tripleo_common/utils/nodes.py | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tripleo_common/actions/parameters.py b/tripleo_common/actions/parameters.py index 377ac4a35..6565f1e6c 100644 --- a/tripleo_common/actions/parameters.py +++ b/tripleo_common/actions/parameters.py @@ -377,12 +377,12 @@ class GenerateFencingParametersAction(base.TripleOAction): # If the MAC isn't in the hostmap, this node hasn't been # provisioned, so no fencing parameters are necessary - if mac_addr not in hostmap: + if hostmap and mac_addr not in hostmap: continue # Build up fencing parameters based on which Ironic driver this # node is using - if node["pm_type"] == "pxe_ssh": + if hostmap and node["pm_type"] == "pxe_ssh": # Ironic fencing driver node_data["agent"] = "fence_ironic" params["auth_url"] = self.os_auth["auth_url"] @@ -401,7 +401,9 @@ class GenerateFencingParametersAction(base.TripleOAction): params["ipaddr"] = node["pm_addr"] params["passwd"] = node["pm_password"] params["login"] = node["pm_user"] - params["pcmk_host_list"] = hostmap[mac_addr]["compute_name"] + if hostmap: + params["pcmk_host_list"] = \ + hostmap[mac_addr]["compute_name"] if "pm_port" in node: params["ipport"] = node["pm_port"] if self.ipmi_lanplus: diff --git a/tripleo_common/utils/nodes.py b/tripleo_common/utils/nodes.py index 76d4d056c..13a5c0f4d 100644 --- a/tripleo_common/utils/nodes.py +++ b/tripleo_common/utils/nodes.py @@ -634,7 +634,10 @@ def generate_hostmap(baremetal_client, compute_client): for port in baremetal_client.port.list(node=bm_node.uuid): hostmap[port.address] = {"compute_name": node.name, "baremetal_name": bm_node.name} - return hostmap + if hostmap == {}: + return None + else: + return hostmap def run_nova_cell_v2_discovery():