Skip to content

Commit

Permalink
It looks like they changed the error message from "Bean is not valid"…
Browse files Browse the repository at this point in the history
… to "Object is not valid"
  • Loading branch information
nhandler committed Aug 4, 2016
1 parent 0913a5c commit 3131e98
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions paasta_tools/marathon_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,9 +1111,9 @@ def kill_task(client, app_id, task_id, scale):
# Marathon allows you to kill and scale in one action, but this is not
# idempotent. If you kill&scale the same task ID twice, the number of instances
# gets decremented twice. This can lead to a situation where kill&scaling the
# last task decrements the number of instances below zero, causing a "Bean is not
# valid" message.
if e.error_message == 'Bean is not valid' and e.status_code == 422:
# last task decrements the number of instances below zero, causing an "Object is not
# valid" message or a "Bean is not valid" message.
if 'is not valid' in e.error_message and e.status_code == 422:
log.debug("Probably tried to kill a task id that didn't exist. Continuing.")
return []
elif 'does not exist' in e.error_message and e.status_code == 404:
Expand All @@ -1132,7 +1132,7 @@ def kill_given_tasks(client, task_ids, scale):
# a task in the interface and kill it, yet by the time it tries to kill
# it, it is already gone. This is not really a failure condition, so we
# swallow this error.
if e.error_message == 'Bean is not valid' and e.status_code == 422:
if 'is not valid' in e.error_message and e.status_code == 422:
log.debug("Probably tried to kill a task id that didn't exist. Continuing.")
return []
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_marathon_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2264,7 +2264,7 @@ def test_kill_tasks_passes_catches_fewer_than_error():
bad_fake_response = mock.Mock()
bad_fake_response.status_code = 422
bad_fake_response.json.return_value = {
"message": "Bean is not valid",
"message": "Object is not valid",
"errors": [{"attribute": "instances", "error": "must be greater than or equal to 0"}],
}
fake_client.kill_task.side_effect = MarathonHttpError(response=bad_fake_response)
Expand Down

0 comments on commit 3131e98

Please sign in to comment.