From f86b2b4c55b2aa10612388e75f604faae969971a Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Fri, 21 Sep 2018 17:32:18 -0400 Subject: [PATCH] config: ignore missing server_id from the stack When blacklisting nodes on the overcloud, we don't want to generated a configuration with these servers. This patch ignore the server when server_id can't be found in the stack when generating the configuration of the overcloud. A warning is shown so the operator knows this server isn't part of the configuration, probably due to blacklisting. If getting the server name fails for another reason than a KeyError, we fail the configuration generation and raise an exception with the error message. Change-Id: Ie7660894050e5eca251aaf8c10f0cc7e7d837dfc Closes-Bug: #1793605 (cherry picked from commit 272bd17c304d7d047ed75679568a09e9ebf7865b) --- ...sted_serverid_config-e079e64e8a04cdb4.yaml | 7 +++++++ tripleo_common/utils/config.py | 20 ++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/blacklisted_serverid_config-e079e64e8a04cdb4.yaml diff --git a/releasenotes/notes/blacklisted_serverid_config-e079e64e8a04cdb4.yaml b/releasenotes/notes/blacklisted_serverid_config-e079e64e8a04cdb4.yaml new file mode 100644 index 000000000..de420e65b --- /dev/null +++ b/releasenotes/notes/blacklisted_serverid_config-e079e64e8a04cdb4.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes `bug 1793605 `__ so + when nodes are blacklisted, they are not included in the Overcloud config. + A warning will show that the server_id that was ignored if the it can't + be found in the stack. diff --git a/tripleo_common/utils/config.py b/tripleo_common/utils/config.py index 6d831e699..54b2a1b13 100644 --- a/tripleo_common/utils/config.py +++ b/tripleo_common/utils/config.py @@ -294,9 +294,23 @@ class Config(object): [i for i in config_dict['inputs'] if i['name'] == 'deploy_server_id'].pop() deploy_server_id_input['value'] = server_id - server_deployments.setdefault( - server_names[server_id], - []).append(config_dict) + + # We don't want to fail if server_id can't be found, as it's + # most probably due to blacklisted nodes. However we fail for + # other errors. + try: + server_deployments.setdefault( + server_names[server_id], + []).append(config_dict) + except KeyError: + self.log.warning('Server with id %s is ignored from config ' + '(may be blacklisted)' % server_id) + # continue the loop as this server_id is probably excluded + continue + except Exception as err: + err_msg = ('Error retrieving server name from this server_id: ' + '%s with this error: %s' % server_id, err) + raise Exception(err_msg) role = self.get_role_from_server_id(stack, server_id) role_deployments = role_deployment_names.setdefault(role, {})