Skip to content

Commit

Permalink
include errors in exception
Browse files Browse the repository at this point in the history
  • Loading branch information
kthare10 committed Apr 18, 2024
1 parent 9df0e7c commit 146bcbc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fabrictestbed_extensions/fablib/fablib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ def __can_allocate_node_in_worker(

worker_maint_info = site.maintenance_info.get(worker.name)
if worker_maint_info and worker_maint_info.state != "Active":
msg = f"Node cannot be allocated on {worker.name}, {worker.name} is in {worker_maint_info.state}."
msg = f"Node cannot be allocated on {worker.name}, {worker.name} is in {worker_maint_info.state}!"
return False, msg

allocated_core = allocated.setdefault("core", 0)
Expand Down
11 changes: 3 additions & 8 deletions fabrictestbed_extensions/fablib/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,9 +1147,7 @@ def add_node(
node.delete()
node = None
if raise_exception:
raise ValueError(
f"{name} cannot be allocated as requested on site: {site}. Reason: {error}"
)
raise ValueError(error)
return node

def get_object_by_reservation(
Expand Down Expand Up @@ -2654,12 +2652,9 @@ def validate(self, raise_exception: bool = True) -> Tuple[bool, Dict[str, str]]:
)
if not status:
nodes_to_remove.append(n)
if raise_exception:
print(f"{n.get_name()}: {error}")
else:
errors[n.get_name()] = error
errors[n.get_name()] = error
for n in nodes_to_remove:
n.delete()
if raise_exception and len(errors):
raise Exception("Slice validation failed!")
raise Exception(f"Slice validation failed - {errors}!")
return len(errors) == 0, errors

0 comments on commit 146bcbc

Please sign in to comment.