Enhanced checkdisk for undercloud

The main issue with the current check is, we do not take into
account specific locations that can have a dedicated volume.

In order to correct that, we provide a list of locations known
for needing disk space, set a bottom limit, and check what is
actually mounted on the node.
Based on that, we loop on the "mounted volume of interest", and
check the free disk space for each of them.

That way, we ensure we can, at least, deploy the undercloud
without any trouble.

As we have now a fixed list, this can also help operators understanding
WHERE space needs to be allocated, and to what extend.

This patch also take into account the future deprecation of top-level
facts in Ansible.

Please note: the listed "min_size" are the really minimal space needed,
and are probably not sufficient for a productive environment.

Another patch regarding the documentation will be provided once this
change is accepted and merged, in order to reflect this new mode of
calculation.

Change-Id: I71cf319270bfec50304f24a09da34d0ea8b1ecd8
This commit is contained in:
Cédric Jeanneret 2018-07-20 12:34:40 +02:00
parent 5e7c25c124
commit f911acd54b
4 changed files with 37 additions and 24 deletions

View File

@ -0,0 +1,5 @@
---
features:
- Allows to list specific directories to check
- Matches listed directories to actual mounts
- Ensure sufficient free space is available on volumes of interest

View File

@ -1,19 +1,21 @@
- name: debug
debug:
msg: "{{a_mounts}}"
- name: Set a constant defining number of Bytes in 1 GB
set_fact:
const_bytes_in_gb: 1073741824
- name: Verify disk space in /var (if it exists)
fail: msg="The available space on the /var partition is {{ (item.size_available|int / const_bytes_in_gb|int)|round(1) }} GB, but it should be at least {{ min_undercloud_disk_gb }} GB."
with_items: "{{ ansible_mounts }}"
when: "'/var' == item.mount"
failed_when: "min_undercloud_disk_gb|int * const_bytes_in_gb|int >= item.size_available|int"
# Notify the next task that we've checked /var (and that it exists)
changed_when: True
register: previous
- name: filter out directories that are not a mount path
set_fact:
mounted_dirs: "{{ a_mounts |map(attribute='mount') | intersect(volumes|map(attribute='mount')|list)}}"
- name: Verify root disk space
fail: msg="The available space on the root partition is {{ (item.size_available|int / const_bytes_in_gb|int)|round(1) }} GB, but it should be at least {{ min_undercloud_disk_gb }} GB."
with_items: "{{ ansible_mounts }}"
# Only run this when /var doesn't exist
when: "not previous.changed and '/' == item.mount"
failed_when: "min_undercloud_disk_gb|int * const_bytes_in_gb|int >= item.size_available|int"
- name: loop on existing volumes, check available space
fail:
msg: "Minimum required for {{ item.mount }}: {{ volumes | selectattr('mount', 'equalto', item.mount) | map(attribute='min_size') | list | join('') }}G - volume free space: {{ (item.size_available|int / const_bytes_in_gb|int) |round(1) }}"
failed_when: "(volumes | selectattr('mount', 'equalto', item.mount) | map(attribute='min_size') | list | join('')|int) >= (item.size_available|int / const_bytes_in_gb|int) |int"
loop: "{{ a_mounts }}"
loop_control:
label: "{{ item.mount }}"
when: "item.mount in mounted_dirs"

View File

@ -7,13 +7,15 @@
Make sure that the root partition on the undercloud node is large
enough before starting an upgrade
We first check for an explicit `/var` mount point since that's
where we store logs and images and if it doesn't exist, we
fall back to `/`.
http://tripleo.org/environments/environments.html#id5
groups:
- pre-upgrade
min_undercloud_disk_gb: 10
volumes:
- {mount: /var/lib/docker, min_size: 10}
- {mount: /var/lib/config-data, min_size: 3}
- {mount: /var, min_size: 16}
- {mount: /, min_size: 20}
a_mounts: "{{hostvars[inventory_hostname].ansible_facts.mounts}}"
tasks:
- include_tasks: tasks/disk_space.yaml

View File

@ -6,14 +6,18 @@
description: >
Make sure that the root partition on the undercloud node is large enough.
We first check for an explicit `/var` mount point since that's
where we store logs and images and if it doesn't exist, we
fall back to `/`.
http://tripleo.org/environments/environments.html#id5
groups:
- prep
- pre-introspection
min_undercloud_disk_gb: 60
volumes:
- {mount: /var/lib/docker, min_size: 10}
- {mount: /var/lib/config-data, min_size: 3}
- {mount: /var/log, min_size: 3}
- {mount: /usr, min_size: 5}
- {mount: /var, min_size: 20}
- {mount: /, min_size: 25}
a_mounts: "{{hostvars[inventory_hostname].ansible_facts.mounts}}"
tasks:
- include_tasks: tasks/disk_space.yaml