Skip to content

Commit f6bd897

Browse files
szaheropenshift-merge-bot[bot]
authored andcommitted
fix: RayJob submit now uses the API client set via set_api_client()
The vendored RayjobApi and RayClusterApi were creating their own Kubernetes clients by calling config.load_kube_config() directly, ignoring the client provided through set_api_client(). This caused 403 errors when authenticating with a custom token, as the request would fall back to the default kubeconfig or in-cluster service account. Override the vendored API instances after construction with ones that use the SDK's global API client, consistent with how the rest of the SDK (Kueue, Cluster) handles authentication. Signed-off-by: Saad Zaher <szaher@redhat.com>
1 parent dd98ce0 commit f6bd897

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/codeflare_sdk/ray/rayjobs/rayjob.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import warnings
2323
from typing import Dict, Any, Optional, Tuple, Union
2424

25+
from kubernetes import client
2526
from ray.runtime_env import RuntimeEnv
2627
from codeflare_sdk.common.kueue.kueue import (
2728
get_default_kueue_name,
@@ -39,6 +40,7 @@
3940
process_runtime_env,
4041
)
4142

43+
from ...common.kubernetes_cluster.auth import config_check, get_api_client
4244
from ...common.utils import get_current_namespace
4345
from ...common.utils.validation import validate_ray_version_compatibility
4446

@@ -169,8 +171,13 @@ def __init__(
169171
self.cluster_name = cluster_name
170172
logger.info(f"Using existing cluster: {self.cluster_name}")
171173

174+
config_check()
175+
k8s_client = get_api_client()
172176
self._api = RayjobApi()
177+
self._api.api = client.CustomObjectsApi(k8s_client)
173178
self._cluster_api = RayClusterApi()
179+
self._cluster_api.api = client.CustomObjectsApi(k8s_client)
180+
self._cluster_api.core_v1_api = client.CoreV1Api(k8s_client)
174181

175182
logger.info(f"Initialized RayJob: {self.name} in namespace: {self.namespace}")
176183

0 commit comments

Comments
 (0)