diff options
author | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-07-28 13:40:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-28 13:40:54 +0200 |
commit | d0761aee7107dffa4803f39b2aaecb660d767752 (patch) | |
tree | 22246d0a0c335b48c65207b6ad5a064b3eee7b77 /roles/openshift_health_checker/openshift_checks | |
parent | 4a442d87006bdd535eb5035d122a6b5226555da2 (diff) | |
parent | 8af18393771ed5679932b05e34fc1d941f7dd51e (diff) | |
download | openshift-d0761aee7107dffa4803f39b2aaecb660d767752.tar.gz openshift-d0761aee7107dffa4803f39b2aaecb660d767752.tar.bz2 openshift-d0761aee7107dffa4803f39b2aaecb660d767752.tar.xz openshift-d0761aee7107dffa4803f39b2aaecb660d767752.zip |
Merge pull request #4372 from juanvallejo/jvallejo/verify-disk-memory-before-upgrade
Add health checks to upgrade playbook
Diffstat (limited to 'roles/openshift_health_checker/openshift_checks')
-rw-r--r-- | roles/openshift_health_checker/openshift_checks/disk_availability.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/roles/openshift_health_checker/openshift_checks/disk_availability.py b/roles/openshift_health_checker/openshift_checks/disk_availability.py index 283461294..39ac0e4ec 100644 --- a/roles/openshift_health_checker/openshift_checks/disk_availability.py +++ b/roles/openshift_health_checker/openshift_checks/disk_availability.py @@ -35,6 +35,15 @@ class DiskAvailability(OpenShiftCheck): }, } + # recommended disk space for each location under an upgrade context + recommended_disk_upgrade_bytes = { + '/var': { + 'masters': 10 * 10**9, + 'nodes': 5 * 10 ** 9, + 'etcd': 5 * 10 ** 9, + }, + } + def is_active(self): """Skip hosts that do not have recommended disk space requirements.""" group_names = self.get_var("group_names", default=[]) @@ -80,9 +89,34 @@ class DiskAvailability(OpenShiftCheck): config_bytes = max(config.get(name, 0) for name in group_names) * 10**9 recommended_bytes = config_bytes or recommended_bytes + # if an "upgrade" context is set, update the minimum disk requirement + # as this signifies an in-place upgrade - the node might have the + # required total disk space, but some of that space may already be + # in use by the existing OpenShift deployment. + context = self.get_var("r_openshift_health_checker_playbook_context", default="") + if context == "upgrade": + recommended_upgrade_paths = self.recommended_disk_upgrade_bytes.get(path, {}) + if recommended_upgrade_paths: + recommended_bytes = config_bytes or max(recommended_upgrade_paths.get(name, 0) + for name in group_names) + if free_bytes < recommended_bytes: free_gb = float(free_bytes) / 10**9 recommended_gb = float(recommended_bytes) / 10**9 + msg = ( + 'Available disk space in "{}" ({:.1f} GB) ' + 'is below minimum recommended ({:.1f} GB)' + ).format(path, free_gb, recommended_gb) + + # warn if check failed under an "upgrade" context + # due to limits imposed by the user config + if config_bytes and context == "upgrade": + msg += ('\n\nMake sure to account for decreased disk space during an upgrade\n' + 'due to an existing OpenShift deployment. Please check the value of\n' + ' openshift_check_min_host_disk_gb={}\n' + 'in your Ansible inventory, and lower the recommended disk space availability\n' + 'if necessary for this upgrade.').format(config_bytes) + return { 'failed': True, 'msg': ( |