Beispiel #1
0
def stop_container(name):
    try:
        cli.stop(name, timeout=5)
        print_utils.okblue("stopped container %s" % name)
    except Exception as e:
        if "No such container" in str(e):
            return
        raise e
Beispiel #2
0
def remove_existing_container(name):
    try:
        cli.remove_container(name, force=True)
        print_utils.okblue("removed container %s" % name)
    except Exception as e:
        if "No such container" in str(e):
            return
        raise e
Beispiel #3
0
 def stop_container(self, container_name):
     container_name = self.namespace + container_name
     try:
         super(Client, self).stop(container_name, timeout=5)
         print_utils.okblue("stopped container %s" % container_name)
     except Exception as e:
         if "No such container" in str(e):
             return
         raise e
Beispiel #4
0
 def remove_existing_container(self, container_name):
     container_name = self.namespace + container_name
     try:
         super(Client, self).remove_container(container_name, force=True)
         print_utils.okblue("removed container %s" % container_name)
     except Exception as e:
         if "No such container" in str(e):
             return
         raise e
Beispiel #5
0
def run_peloton(applications):
    print_utils.okblue('docker image "uber/peloton" has to be built first '
                       "locally by running IMAGE=uber/peloton make docker")

    for app, func in APP_START_ORDER.iteritems():
        if app in applications:
            should_disable = applications[app]
            if should_disable:
                continue
        APP_START_ORDER[app](config)
Beispiel #6
0
    def _setup_peloton(self):
        print_utils.okblue(
            'docker image "uber/peloton" has to be built first '
            "locally by running IMAGE=uber/peloton make docker"
        )

        for app, func in self.APP_START_ORDER.iteritems():
            if app in self.disabled_applications:
                should_disable = self.disabled_applications[app]
                if should_disable:
                    continue
            self.APP_START_ORDER[app]()
Beispiel #7
0
def run_peloton(applications, enable_k8s=False):
    print_utils.okblue('docker image "uber/peloton" has to be built first '
                       "locally by running IMAGE=uber/peloton make docker")

    for app, func in APP_START_ORDER.iteritems():
        if app in applications:
            should_disable = applications[app]
            if should_disable:
                continue
        # TODO: Define class PelotonCluster, set startup ordering and
        # enable_k8s there.
        APP_START_ORDER[app](config, enable_k8s)
Beispiel #8
0
def run_mesos(config):
    # Remove existing containers first.
    teardown_mesos(config)

    # Run zk
    cli.pull(config["zk_image"])
    container = cli.create_container(
        name=config["zk_container"],
        hostname=config["zk_container"],
        host_config=cli.create_host_config(
            port_bindings={config["default_zk_port"]: config["local_zk_port"]
                           }),
        image=config["zk_image"],
        detach=True,
    )
    cli.start(container=container.get("Id"))
    print_utils.okgreen("started container %s" % config["zk_container"])

    # TODO: add retry
    print_utils.okblue("sleep 20 secs for zk to come up")
    time.sleep(20)

    # Run mesos master
    cli.pull(config["mesos_master_image"])
    container = cli.create_container(
        name=config["mesos_master_container"],
        hostname=config["mesos_master_container"],
        volumes=["/files"],
        ports=[repr(config["master_port"])],
        host_config=cli.create_host_config(
            port_bindings={config["master_port"]: config["master_port"]},
            binds=[
                work_dir + "/files:/files",
                work_dir + "/mesos_config/etc_mesos-master:/etc/mesos-master",
            ],
            privileged=True,
        ),
        environment=[
            "MESOS_AUTHENTICATE_HTTP_READWRITE=true",
            "MESOS_AUTHENTICATE_FRAMEWORKS=true",
            # TODO: Enable following flags for fully authentication.
            "MESOS_AUTHENTICATE_HTTP_FRAMEWORKS=true",
            "MESOS_HTTP_FRAMEWORK_AUTHENTICATORS=basic",
            "MESOS_CREDENTIALS=/etc/mesos-master/credentials",
            "MESOS_LOG_DIR=" + config["log_dir"],
            "MESOS_PORT=" + repr(config["master_port"]),
            "MESOS_ZK=zk://{0}:{1}/mesos".format(
                utils.get_container_ip(config["zk_container"]),
                config["default_zk_port"],
            ),
            "MESOS_QUORUM=" + repr(config["quorum"]),
            "MESOS_REGISTRY=" + config["registry"],
            "MESOS_WORK_DIR=" + config["work_dir"],
        ],
        image=config["mesos_master_image"],
        entrypoint="bash /files/run_mesos_master.sh",
        detach=True,
    )
    cli.start(container=container.get("Id"))
    master_container = config["mesos_master_container"]
    print_utils.okgreen("started container %s" % master_container)

    # Run mesos slaves
    cli.pull(config['mesos_slave_image'])
    for i in range(0, config['num_agents']):
        run_mesos_agent(config, i, i)
    for i in range(0, config.get('num_exclusive_agents', 0)):
        run_mesos_agent(config,
                        i,
                        config['num_agents'] + i,
                        is_exclusive=True,
                        exclusive_label_value=config.get(
                            'exclusive_label_value', ''))