Skip to content

Commit

Permalink
Merge pull request Yelp#808 from Yelp/fix-dynamic-reservation-metastatus
Browse files Browse the repository at this point in the history
Fix metastatus
  • Loading branch information
nhandler authored Sep 30, 2016
2 parents 2ca4df0 + 1bf49a0 commit 9fb3ad9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions paasta_tools/paasta_metastatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_mesos_cpu_status(metrics, mesos_state):

for slave in mesos_state['slaves']:
for role in slave['reserved_resources']:
used -= slave['reserved_resources'][role]['cpus']
used += slave['reserved_resources'][role]['cpus']

available = total - used
return total, used, available
Expand Down Expand Up @@ -171,7 +171,7 @@ def assert_memory_health(metrics, mesos_state, threshold=10):

for slave in mesos_state['slaves']:
for role in slave['reserved_resources']:
used -= slave['reserved_resources'][role]['mem']
used += slave['reserved_resources'][role]['mem']

try:
perc_used = percent_used(total, used)
Expand Down Expand Up @@ -199,7 +199,7 @@ def assert_disk_health(metrics, mesos_state, threshold=10):

for slave in mesos_state['slaves']:
for role in slave['reserved_resources']:
used -= slave['reserved_resources'][role]['disk']
used += slave['reserved_resources'][role]['disk']

try:
perc_used = percent_used(total, used)
Expand Down
10 changes: 7 additions & 3 deletions tests/test_paasta_metastatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ def test_get_mesos_cpu_status():
fake_mesos_state = {
'slaves': [
{
'reserved_resources': {},
'reserved_resources': {
'some-role': {
'cpus': 1,
},
},
},
],
}
total, used, available = paasta_metastatus.get_mesos_cpu_status(fake_metrics, fake_mesos_state)
assert total == 3
assert used == 1
assert available == 2
assert used == 2
assert available == 1


def test_ok_cpu_health():
Expand Down

0 comments on commit 9fb3ad9

Please sign in to comment.