def kill_node(config_file, yes, override_cluster_name):
    """Kills a random Raylet worker."""

    config = yaml.load(open(config_file).read())
    if override_cluster_name is not None:
        config["cluster_name"] = override_cluster_name
    config = _bootstrap_config(config)

    confirm("This will kill a node in your cluster", yes)

    provider = get_node_provider(config["provider"], config["cluster_name"])
    try:
        nodes = provider.non_terminated_nodes({TAG_RAY_NODE_TYPE: "worker"})
        node = random.choice(nodes)
        logger.info("kill_node: Terminating worker {}".format(node))

        updater = NodeUpdaterThread(
            node_id=node,
            provider_config=config["provider"],
            provider=provider,
            auth_config=config["auth"],
            cluster_name=config["cluster_name"],
            file_mounts=config["file_mounts"],
            initialization_commands=[],
            setup_commands=[],
            runtime_hash="")

        _exec(updater, "ray stop", False, False)

        time.sleep(5)

        if config.get("provider", {}).get("use_internal_ips", False) is True:
            node_ip = provider.internal_ip(node)
        else:
            node_ip = provider.external_ip(node)
    finally:
        provider.cleanup()

    return node_ip
def kill_node ( config_file , yes , override_cluster_name ) : config = yaml . load ( open ( config_file ) . read ( ) ) if override_cluster_name is not None : config [ "cluster_name" ] = override_cluster_name config = _bootstrap_config ( config ) confirm ( "This will kill a node in your cluster" , yes ) provider = get_node_provider ( config [ "provider" ] , config [ "cluster_name" ] ) try : nodes = provider . non_terminated_nodes ( { TAG_RAY_NODE_TYPE : "worker" } ) node = random . choice ( nodes ) logger . info ( "kill_node: Terminating worker {}" . format ( node ) ) updater = NodeUpdaterThread ( node_id = node , provider_config = config [ "provider" ] , provider = provider , auth_config = config [ "auth" ] , cluster_name = config [ "cluster_name" ] , file_mounts = config [ "file_mounts" ] , initialization_commands = [ ] , setup_commands = [ ] , runtime_hash = "" ) _exec ( updater , "ray stop" , False , False ) time . sleep ( 5 ) if config . get ( "provider" , { } ) . get ( "use_internal_ips" , False ) is True : node_ip = provider . internal_ip ( node ) else : node_ip = provider . external_ip ( node ) finally : provider . cleanup ( ) return node_ip
Kills a random Raylet worker.