def set_status(cluster_cr: Dict[str, Any], cluster_name: str, status: str) -> None: # TODO: Add retry logic in case of 409 due to old resource version. cluster_cr["status"] = {"phase": status} custom_objects_api()\ .patch_namespaced_custom_object_status(namespace=RAY_NAMESPACE, group="cluster.ray.io", version="v1", plural="rayclusters", name=cluster_name, body=cluster_cr)
def namespaced_cr_stream(namespace) -> Iterator: w = Watch() return w.stream(custom_objects_api().list_namespaced_custom_object, namespace=namespace, group=RAY_API_GROUP, version=RAY_API_VERSION, plural=RAYCLUSTER_PLURAL)
def _set_status(cluster_name: str, cluster_namespace: str, status: str) -> None: cluster_cr = custom_objects_api()\ .get_namespaced_custom_object(namespace=cluster_namespace, group=RAY_API_GROUP, version=RAY_API_VERSION, plural=RAYCLUSTER_PLURAL, name=cluster_name) cluster_cr["status"] = {"phase": status} custom_objects_api()\ .patch_namespaced_custom_object_status(namespace=cluster_namespace, group=RAY_API_GROUP, version=RAY_API_VERSION, plural=RAYCLUSTER_PLURAL, name=cluster_name, body=cluster_cr)
def cluster_cr_stream() -> Iterator: w = Watch() return w.stream(custom_objects_api().list_namespaced_custom_object, namespace=RAY_NAMESPACE, group="cluster.ray.io", version="v1", plural="rayclusters")
def cluster_scoped_cr_stream() -> Iterator: w = Watch() return w.stream( custom_objects_api().list_cluster_custom_object, group=RAY_API_GROUP, version=RAY_API_VERSION, plural=RAYCLUSTER_PLURAL)
def _set_status(cluster_name: str, cluster_namespace: str, phase: str) -> None: cluster_cr = custom_objects_api()\ .get_namespaced_custom_object( namespace=cluster_namespace, group=RAY_API_GROUP, version=RAY_API_VERSION, plural=RAYCLUSTER_PLURAL, name=cluster_name) status = cluster_cr.get("status", {}) autoscaler_retries = status.get(AUTOSCALER_RETRIES_FIELD, 0) if phase == STATUS_AUTOSCALING_EXCEPTION: autoscaler_retries += 1 cluster_cr["status"] = { "phase": phase, AUTOSCALER_RETRIES_FIELD: autoscaler_retries } custom_objects_api()\ .patch_namespaced_custom_object_status(namespace=cluster_namespace, group=RAY_API_GROUP, version=RAY_API_VERSION, plural=RAYCLUSTER_PLURAL, name=cluster_name, body=cluster_cr)