Skip to content

Commit 21eea80

Browse files
Made local_queue parameter optional
1 parent e30d450 commit 21eea80

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/codeflare_sdk/utils/generate_yaml.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from os import urandom
3131
from base64 import b64encode
3232
from urllib3.util import parse_url
33+
from kubernetes.client.exceptions import ApiException
3334

3435

3536
def read_template(template):
@@ -191,8 +192,11 @@ def get_default_kueue_name(namespace: str):
191192
namespace=namespace,
192193
plural="localqueues",
193194
)
194-
except Exception as e: # pragma: no cover
195-
return _kube_api_error_handling(e)
195+
except ApiException as e: # pragma: no cover
196+
if e.status == 404 or e.status == 403:
197+
return
198+
else:
199+
return _kube_api_error_handling(e)
196200
for lq in local_queues["items"]:
197201
if (
198202
"annotations" in lq["metadata"]
@@ -201,9 +205,6 @@ def get_default_kueue_name(namespace: str):
201205
== "true"
202206
):
203207
return lq["metadata"]["name"]
204-
raise ValueError(
205-
"Default Local Queue with kueue.x-k8s.io/default-queue: true annotation not found please create a default Local Queue or provide the local_queue name in Cluster Configuration"
206-
)
207208

208209

209210
def local_queue_exists(namespace: str, local_queue_name: str):
@@ -228,7 +229,9 @@ def local_queue_exists(namespace: str, local_queue_name: str):
228229

229230
def add_queue_label(item: dict, namespace: str, local_queue: Optional[str]):
230231
lq_name = local_queue or get_default_kueue_name(namespace)
231-
if not local_queue_exists(namespace, lq_name):
232+
if lq_name == None:
233+
return
234+
elif not local_queue_exists(namespace, lq_name):
232235
raise ValueError(
233236
"local_queue provided does not exist or is not in this namespace. Please provide the correct local_queue name in Cluster Configuration"
234237
)

0 commit comments

Comments
 (0)