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
This commit is contained in:
Cédric Jeanneret 2018-07-27 14:59:42 +02:00
parent 0879570c5d
commit 54e5ae9be6
4 changed files with 36 additions and 2 deletions

View File

@ -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'

View File

@ -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.

View File

@ -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")]

View File

@ -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