Skip to content

Commit e60aa44

Browse files
committed
Add try except for CW link generation
1 parent 1f75180 commit e60aa44

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/hyperpod_cli/commands/pod.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,17 @@ def get_log(
7272
job_name, pod, namespace=namespace
7373
)
7474
click.echo(result)
75-
76-
cloudwatch_link = get_logs_service.generate_cloudwatch_link(pod, namespace=namespace)
77-
if cloudwatch_link:
78-
click.echo(cloudwatch_link)
7975
except Exception as e:
8076
sys.exit(
8177
f"Unexpected error happens when trying to get logs for training job {job_name} : {e}"
8278
)
83-
79+
80+
try:
81+
cloudwatch_link = get_logs_service.generate_cloudwatch_link(pod, namespace=namespace)
82+
if cloudwatch_link:
83+
click.echo(cloudwatch_link)
84+
except Exception as e:
85+
click.echo(f"WARNING: Failed to generate container insights cloudwatch link: {e}")
8486

8587
def _exec_command_required_option_pod_and_all_pods():
8688
class OptionRequiredClass(click.Command):

src/hyperpod_cli/service/get_logs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ def generate_cloudwatch_link(
110110
cloudwatch_url = self.get_log_url(eks_cluster_name, region, node_name, pod_name, namespace, container_name, container_id)
111111

112112
if not validate_region_and_cluster_name(region, eks_cluster_name):
113-
return 'Failed to validate Eks cluster name and region'
113+
raise ValueError('Eks cluster name or cluster region is invalid.')
114114

115115
if not re.match(CONTAINER_INSIGHTS_LOG_REGEX_PATTERN, cloudwatch_url):
116-
return 'Failed to validate cloudwatch log url. Please verify node name, pod container name and container id are valid'
116+
raise ValueError("Failed to validate cloudwatch log url. Please make sure pod's node name, container name and container id are valid")
117117

118118
cloudwatch_link = f'The pod cloudwatch log stream link is {cloudwatch_url}'
119119
else:

0 commit comments

Comments
 (0)