Skip to content

Commit

Permalink
lower disk requirement on "upgrade" context
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Jun 23, 2017
1 parent 26bc5ec commit 44fef09
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ def run(self, tmp, task_vars):
configured_min = int(get_var(task_vars, "openshift_check_min_host_disk_gb", default=0)) * 10**9
min_free_bytes = configured_min or recommended_min

# if an "upgrade" context is set, lower 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 = get_var(task_vars, "r_openshift_health_checker_playbook_context", default="")
if context == "upgrade":
upgrade_min_required_diskspace = 5.0 * 10**9
if free_bytes < upgrade_min_required_diskspace:
return {
'failed': True,
'msg': (
'Available disk space ({:.1f} GB) for the volume containing '
'"/var" is below minimum recommended space for an upgrade ({:.1f} GB).'
).format(float(free_bytes) / 10**9, float(upgrade_min_required_diskspace) / 10**9)
}

return {}

if free_bytes < min_free_bytes:
return {
'failed': True,
Expand Down
57 changes: 56 additions & 1 deletion roles/openshift_health_checker/test/disk_availability_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,62 @@ def test_fails_with_insufficient_disk_space(group_names, configured_min, ansible

assert result['failed']
for word in 'below recommended'.split() + extra_words:
assert word in result['msg']
assert word in result.get('msg', '')


@pytest.mark.parametrize('group_names,context,ansible_mounts,failed,extra_words', [
(
['nodes', 'masters'],
"upgrade",
[{
'mount': '/',
# not enough space for a master
# even under an "upgrade" context
'size_available': 1 * 10**9 + 1,
'size_total': 21 * 10**9 + 1,
}],
True,
["1.0 GB"],
),
(
['nodes', 'masters'],
"upgrade",
[{
'mount': '/',
# not enough space for a master,
# but enough under "upgrade" context
'size_available': 10 * 10**9 + 1,
'size_total': 21 * 10**9 + 1,
}],
False,
[],
),
(
['nodes', 'masters'],
"health",
[{
'mount': '/',
# not enough space for a master,
# "health" context should not lower requirement
'size_available': 20 * 10**9 + 1,
}],
True,
["20.0 GB", "below minimum"],
),
])
def test_min_required_space_decreases_with_upgrade_context(group_names, context, ansible_mounts, failed, extra_words):
task_vars = dict(
r_openshift_health_checker_playbook_context=context,
group_names=group_names,
ansible_mounts=ansible_mounts,
)

check = DiskAvailability(execute_module=fake_execute_module)
result = check.run(tmp=None, task_vars=task_vars)

assert result.get("failed", False) == failed
for word in extra_words:
assert word in result.get('msg', '')


def fake_execute_module(*args):
Expand Down

0 comments on commit 44fef09

Please sign in to comment.