From 54e5ae9be6297b6cb50bc01c2d7543a040ac9524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= Date: Fri, 27 Jul 2018 14:59:42 +0200 Subject: [PATCH] New preflight check for the undercloud: disk space Enable disk space check on the undercloud in order to ensure we have at least the minimal at disposal. The check itself comes from the tripleo-validations repository in order to avoid inconsistencies and do a first step toward ansible-driven validations. Change-Id: Ieea72ce2695683c5fb083887195044acbd6b92ee --- tripleoclient/constants.py | 2 ++ ...ndercloud-disk-space-709ebf574e91ae3a.yaml | 7 +++++ tripleoclient/v1/undercloud_config.py | 2 +- tripleoclient/v1/undercloud_preflight.py | 27 ++++++++++++++++++- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tripleoclient/v1/releasenotes/notes/check-undercloud-disk-space-709ebf574e91ae3a.yaml diff --git a/tripleoclient/constants.py b/tripleoclient/constants.py index d4b5d4dd0..ef26bdd92 100644 --- a/tripleoclient/constants.py +++ b/tripleoclient/constants.py @@ -75,3 +75,5 @@ ENABLE_SSH_ADMIN_STATUS_INTERVAL = 5 ENABLE_SSH_ADMIN_SSH_PORT_TIMEOUT = 300 ADDITIONAL_ARCHITECTURES = ['ppc64le'] + +ANSIBLE_VALIDATION_DIR = '/usr/share/openstack-tripleo-validations/validations' diff --git a/tripleoclient/v1/releasenotes/notes/check-undercloud-disk-space-709ebf574e91ae3a.yaml b/tripleoclient/v1/releasenotes/notes/check-undercloud-disk-space-709ebf574e91ae3a.yaml new file mode 100644 index 000000000..a876dab3a --- /dev/null +++ b/tripleoclient/v1/releasenotes/notes/check-undercloud-disk-space-709ebf574e91ae3a.yaml @@ -0,0 +1,7 @@ +--- +--- +features: + - Enable new preflight check on the undercloud, using ansible playbooks from + openstack-tripleo-validations. + - Check runs differently if we're on a brand new deploy or an upgrade, as we + don't need the same amount of free space. diff --git a/tripleoclient/v1/undercloud_config.py b/tripleoclient/v1/undercloud_config.py index 8daaa0af6..a03f50698 100644 --- a/tripleoclient/v1/undercloud_config.py +++ b/tripleoclient/v1/undercloud_config.py @@ -561,7 +561,7 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False, deploy_args += ['--hieradata-override=%s' % data_file] if CONF.get('enable_validations') and not no_validations: - undercloud_preflight.check(verbose_level) + undercloud_preflight.check(verbose_level, upgrade) deploy_args += ['-e', os.path.join( tht_templates, "environments/tripleo-validations.yaml")] diff --git a/tripleoclient/v1/undercloud_preflight.py b/tripleoclient/v1/undercloud_preflight.py index e0687d1e8..a01c5fd33 100644 --- a/tripleoclient/v1/undercloud_preflight.py +++ b/tripleoclient/v1/undercloud_preflight.py @@ -93,6 +93,30 @@ def _run_live_command(args, env=None, name=None, cwd=None, wait=True): raise RuntimeError(message) +def _check_diskspace(upgrade=False): + """Check undercloud disk space + + This runs a simple ansible playbook located in tripleo-validations + There are currently two playbooks: + - undercloud-disk-space.yaml + - undercloud-disk-space-pre-upgrade.yaml + First one checks minimal disk space for a brand new deploy. + Second one checks minimal disk space for an upgrade. + """ + if upgrade: + playbook = 'undercloud-disk-space-pre-upgrade.yaml' + else: + playbook = 'undercloud-disk-space.yaml' + + utils.run_ansible_playbook(logger=LOG, + workdir=constants.ANSIBLE_VALIDATION_DIR, + playbook=playbook, + inventory='undercloud,', + retries=False, + connection='local', + output_callback='validation_output') + + def _check_hostname(): """Check system hostname configuration @@ -457,7 +481,7 @@ def _validate_architecure_options(): _validate_ppc64le_exclusive_opts(error_handler) -def check(verbose_level): +def check(verbose_level, upgrade=False): # Fetch configuration and use its log file param to add logging to a file utils.load_config(CONF, constants.UNDERCLOUD_CONF_PATH) utils.configure_logging(LOG, verbose_level, CONF['undercloud_log_file']) @@ -467,6 +491,7 @@ def check(verbose_level): # Other validations _check_hostname() _check_memory() + _check_diskspace(upgrade) _check_sysctl() _validate_passwords_file() # Heat templates validations