Skip to content

Commit

Permalink
Allow users to set accepted_resource_roles in marathon yamls. PAASTA-…
Browse files Browse the repository at this point in the history
…2455
  • Loading branch information
EvanKrall committed Jan 16, 2016
1 parent 09bb8fa commit 803b82b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions paasta_tools/marathon_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ def format_marathon_app_dict(self, app_id, docker_url, docker_volumes, service_n
'cmd': self.get_cmd(),
'args': self.get_args(),
}

accepted_resource_roles = self.get_accepted_resource_roles()
if accepted_resource_roles is not None:
complete_config['accepted_resource_roles'] = accepted_resource_roles

log.debug("Complete configuration for instance is: %s", complete_config)
return complete_config

Expand Down Expand Up @@ -430,6 +435,9 @@ def get_bounce_health_params(self, service_namespace_config):
default = {'check_haproxy': True}
return self.config_dict.get('bounce_health_params', default)

def get_accepted_resource_roles(self):
return self.config_dict.get('accepted_resource_roles', None)


def load_service_namespace_config(service, namespace, soa_dir=DEFAULT_SOA_DIR):
"""Attempt to read the configuration for a service's namespace in a more strict fashion.
Expand Down
12 changes: 12 additions & 0 deletions tests/test_marathon_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ def test_format_marathon_app_dict(self):
'health_checks': fake_healthchecks,
'backoff_factor': 2,
'backoff_seconds': mock.ANY,
'accepted_resource_roles': ['ads'],
}
config = marathon_tools.MarathonServiceConfig(
'can_you_dig_it',
Expand All @@ -835,6 +836,7 @@ def test_format_marathon_app_dict(self):
'healthcheck_interval_seconds': 10,
'healthcheck_timeout_seconds': 10,
'healthcheck_max_consecutive_failures': 3,
'accepted_resource_roles': ['ads'],
},
{'desired_state': 'start'}
)
Expand Down Expand Up @@ -1580,6 +1582,16 @@ def test_get_backoff_doesnt_devide_by_zero(self):
"service", "instance", {'instances': 0}, {})
assert marathon_config.get_backoff_seconds() == 1

def test_get_accepted_resource_roles_default(self):
marathon_config = marathon_tools.MarathonServiceConfig(
"service", "instance", {}, {})
assert marathon_config.get_accepted_resource_roles() is None

def test_get_accepted_resource_roles(self):
marathon_config = marathon_tools.MarathonServiceConfig(
"service", "instance", {"accepted_resource_roles": ["ads"]}, {})
assert marathon_config.get_accepted_resource_roles() == ["ads"]


class TestServiceNamespaceConfig(object):

Expand Down

0 comments on commit 803b82b

Please sign in to comment.