Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

marathon tasks with started_at of None are now unhealthy #261

Merged
merged 1 commit into from
Feb 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions paasta_tools/check_marathon_services_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def get_healthy_marathon_instances_for_short_app_id(client, app_id):
healthy_tasks = []
for task in tasks_for_app:
if all([health_check_result.alive for health_check_result in task.health_check_results]) \
and task.started_at is not None \
and datetime_from_utc_to_local(task.started_at) < one_minute_ago:
healthy_tasks.append(task)
return len(healthy_tasks)
Expand Down
19 changes: 19 additions & 0 deletions tests/test_check_marathon_services_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,25 @@ def test_get_healthy_marathon_instances_for_short_app_id_considers_new_tasks_not
assert actual == 3


def test_get_healthy_marathon_instances_for_short_app_id_considers_none_start_time_unhealthy():
fake_client = mock.Mock()

fake_task = mock.Mock()
fake_task.app_id = '/service.instance.foo.bar'
fake_task.started_at = None
mock_result = mock.Mock()
mock_result.alive = True
fake_task.health_check_results = [mock_result]

fakes = [fake_task]
fake_client.list_tasks.return_value = fakes
actual = check_marathon_services_replication.get_healthy_marathon_instances_for_short_app_id(
fake_client,
'service.instance',
)
assert actual == 0


@mock.patch('paasta_tools.check_marathon_services_replication.send_event_if_under_replication')
@mock.patch('paasta_tools.check_marathon_services_replication.get_healthy_marathon_instances_for_short_app_id')
def test_check_healthy_marathon_tasks_for_service_instance(mock_healthy_instances,
Expand Down