Skip to content

Commit

Permalink
Made local_queue parameter optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobbins228 authored and openshift-merge-bot[bot] committed Jul 3, 2024
1 parent e30d450 commit 21eea80
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/codeflare_sdk/utils/generate_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from os import urandom
from base64 import b64encode
from urllib3.util import parse_url
from kubernetes.client.exceptions import ApiException


def read_template(template):
Expand Down Expand Up @@ -191,8 +192,11 @@ def get_default_kueue_name(namespace: str):
namespace=namespace,
plural="localqueues",
)
except Exception as e: # pragma: no cover
return _kube_api_error_handling(e)
except ApiException as e: # pragma: no cover
if e.status == 404 or e.status == 403:
return
else:
return _kube_api_error_handling(e)
for lq in local_queues["items"]:
if (
"annotations" in lq["metadata"]
Expand All @@ -201,9 +205,6 @@ def get_default_kueue_name(namespace: str):
== "true"
):
return lq["metadata"]["name"]
raise ValueError(
"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"
)


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

def add_queue_label(item: dict, namespace: str, local_queue: Optional[str]):
lq_name = local_queue or get_default_kueue_name(namespace)
if not local_queue_exists(namespace, lq_name):
if lq_name == None:
return
elif not local_queue_exists(namespace, lq_name):
raise ValueError(
"local_queue provided does not exist or is not in this namespace. Please provide the correct local_queue name in Cluster Configuration"
)
Expand Down

0 comments on commit 21eea80

Please sign in to comment.