mirror of
https://github.com/wassname/ray.git
synced 2026-07-01 20:57:51 +08:00
[kubernetes][minor] Operator garbage collection fix (#13392)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import copy
|
||||
import logging
|
||||
import os
|
||||
from typing import Any, Dict, Iterator, List
|
||||
from typing import Any, Dict, Iterator
|
||||
|
||||
from kubernetes.watch import Watch
|
||||
|
||||
@@ -39,15 +39,6 @@ PROVIDER_CONFIG = {
|
||||
|
||||
root_logger = logging.getLogger("ray")
|
||||
root_logger.setLevel(logging.getLevelName("DEBUG"))
|
||||
"""
|
||||
ownerReferences:
|
||||
- apiVersion: apps/v1
|
||||
controller: true
|
||||
blockOwnerDeletion: true
|
||||
kind: ReplicaSet
|
||||
name: my-repset
|
||||
uid: d9607e19-f88f-11e6-a518-42010a800195
|
||||
"""
|
||||
|
||||
|
||||
def config_path(cluster_name: str) -> str:
|
||||
@@ -68,23 +59,17 @@ def cluster_cr_stream() -> Iterator:
|
||||
def cr_to_config(cluster_resource: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""Convert RayCluster custom resource to a ray cluster config for use by the
|
||||
autoscaler."""
|
||||
cr_spec = cluster_resource["spec"]
|
||||
cr_meta = cluster_resource["metadata"]
|
||||
config = translate(cr_spec, dictionary=CONFIG_FIELDS)
|
||||
pod_types = cr_spec["podTypes"]
|
||||
config["available_node_types"] = get_node_types(
|
||||
pod_types, cluster_name=cr_meta["name"], cluster_uid=cr_meta["uid"])
|
||||
config["cluster_name"] = cr_meta["name"]
|
||||
config = translate(cluster_resource["spec"], dictionary=CONFIG_FIELDS)
|
||||
config["available_node_types"] = get_node_types(cluster_resource)
|
||||
config["cluster_name"] = cluster_resource["metadata"]["name"]
|
||||
config["provider"] = PROVIDER_CONFIG
|
||||
return config
|
||||
|
||||
|
||||
def get_node_types(pod_types: List[Dict[str, Any]], cluster_name: str,
|
||||
cluster_uid: str) -> Dict[str, Any]:
|
||||
cluster_owner_reference = get_cluster_owner_reference(
|
||||
cluster_name, cluster_uid)
|
||||
def get_node_types(cluster_resource: Dict[str, Any]) -> Dict[str, Any]:
|
||||
cluster_owner_reference = get_cluster_owner_reference(cluster_resource)
|
||||
node_types = {}
|
||||
for pod_type in pod_types:
|
||||
for pod_type in cluster_resource["spec"]["podTypes"]:
|
||||
name = pod_type["name"]
|
||||
pod_type_copy = copy.deepcopy(pod_type)
|
||||
pod_type_copy.pop("name")
|
||||
@@ -97,15 +82,15 @@ def get_node_types(pod_types: List[Dict[str, Any]], cluster_name: str,
|
||||
return node_types
|
||||
|
||||
|
||||
def get_cluster_owner_reference(cluster_name: str,
|
||||
cluster_uid: str) -> Dict[str, Any]:
|
||||
def get_cluster_owner_reference(
|
||||
cluster_resource: Dict[str, Any]) -> Dict[str, Any]:
|
||||
return {
|
||||
"apiVersion": "apps/v1",
|
||||
"controller": True,
|
||||
"apiVersion": cluster_resource["apiVersion"],
|
||||
"kind": cluster_resource["kind"],
|
||||
"blockOwnerDeletion": True,
|
||||
"kind": "RayCluster",
|
||||
"name": cluster_name,
|
||||
"uid": cluster_uid
|
||||
"controller": True,
|
||||
"name": cluster_resource["metadata"]["name"],
|
||||
"uid": cluster_resource["metadata"]["uid"]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
"""This script allows you to develop RLlib without needing to compile Ray."""
|
||||
"""This script allows you to develop Ray Python code without needing to compile
|
||||
Ray.
|
||||
See https://docs.ray.io/en/master/development.html#building-ray-python-only"""
|
||||
|
||||
import argparse
|
||||
import click
|
||||
@@ -64,6 +66,7 @@ if __name__ == "__main__":
|
||||
do_link("rllib", force=args.yes, local_path="../../../rllib")
|
||||
do_link("tune", force=args.yes)
|
||||
do_link("autoscaler", force=args.yes)
|
||||
do_link("operator", force=args.yes)
|
||||
do_link("cloudpickle", force=args.yes)
|
||||
do_link("scripts", force=args.yes)
|
||||
do_link("internal", force=args.yes)
|
||||
|
||||
Reference in New Issue
Block a user