Example #1
0
    def get_constraints(self, service_namespace_config):
        """Gets the constraints specified in the service's marathon configuration.

        These are Marathon app constraints. See
        https://mesosphere.github.io/marathon/docs/constraints.html

        Defaults to `GROUP_BY region`. If the service's smartstack configuration
        specifies a `discover` key, then defaults to `GROUP_BY <value of discover>` instead.

        :param service_namespace_config: The service instance's configuration dictionary
        :returns: The constraints specified in the config, or defaults described above
        """
        if 'constraints' in self.config_dict:
            return self.config_dict.get('constraints')
        else:
            discover_level = service_namespace_config.get_discover()
            locations = get_mesos_slaves_grouped_by_attribute(
                attribute=discover_level,
                blacklist=self.get_deploy_blacklist())
            deploy_constraints = deploy_blacklist_to_constraints(
                self.get_deploy_blacklist())
            routing_constraints = [[
                discover_level, "GROUP_BY",
                str(len(locations))
            ]]
            return routing_constraints + deploy_constraints
Example #2
0
def test_deploy_blacklist_to_constraints():
    fake_deploy_blacklist = [["region", "useast1-prod"],
                             ["habitat", "fake_habitat"]]
    expected_constraints = [["region", "UNLIKE", "useast1-prod"],
                            ["habitat", "UNLIKE", "fake_habitat"]]
    actual = utils.deploy_blacklist_to_constraints(fake_deploy_blacklist)
    assert actual == expected_constraints
    def get_constraints(self, service_namespace_config):
        """Gets the constraints specified in the service's marathon configuration.

        These are Marathon app constraints. See
        https://mesosphere.github.io/marathon/docs/constraints.html

        Defaults to `GROUP_BY region`. If the service's smartstack configuration
        specifies a `discover` key, then defaults to `GROUP_BY <value of discover>` instead.

        :param service_namespace_config: The service instance's configuration dictionary
        :returns: The constraints specified in the config, or defaults described above
        """
        if 'constraints' in self.config_dict:
            return self.config_dict.get('constraints')
        else:
            discover_level = service_namespace_config.get_discover()
            locations = get_mesos_slaves_grouped_by_attribute(
                attribute=discover_level, blacklist=self.get_deploy_blacklist())
            deploy_constraints = deploy_blacklist_to_constraints(self.get_deploy_blacklist())
            routing_constraints = [[discover_level, "GROUP_BY", str(len(locations))]]
            return routing_constraints + deploy_constraints
Example #4
0
 def get_deploy_constraints(self):
     return (deploy_blacklist_to_constraints(self.get_deploy_blacklist()) +
             deploy_whitelist_to_constraints(self.get_deploy_whitelist()))
Example #5
0
 def get_deploy_constraints(self):
     return (deploy_blacklist_to_constraints(self.get_deploy_blacklist()) +
             deploy_whitelist_to_constraints(self.get_deploy_whitelist()))
Example #6
0
 def get_deploy_constraints(self):
     return deploy_blacklist_to_constraints(self.get_deploy_blacklist())
Example #7
0
def test_deploy_blacklist_to_constraints():
    fake_deploy_blacklist = [["region", "useast1-prod"], ["habitat", "fake_habitat"]]
    expected_constraints = [["region", "UNLIKE", "useast1-prod"], ["habitat", "UNLIKE", "fake_habitat"]]
    actual = utils.deploy_blacklist_to_constraints(fake_deploy_blacklist)
    assert actual == expected_constraints
Example #8
0
 def get_deploy_constraints(self):
     return deploy_blacklist_to_constraints(self.get_deploy_blacklist())