Skip to content

Commit

Permalink
Use vector-reader cli if new logging pipeline is enabled (#999)
Browse files Browse the repository at this point in the history
Thankfully, this was a pretty easy change - we really only needed to
parametrize the command name being used and the location selector is now
a lot simpler as it'll always be the superregion
  • Loading branch information
nemacysts authored Sep 30, 2024
1 parent 089ec83 commit 055e5cc
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tron/utils/scribereader.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,25 @@ def read_log_stream_for_action_run(
malformed = (
[f"{paasta_logs.malformed_lines} encountered while retrieving logs"] if paasta_logs.malformed_lines else []
)
try:
location_selector = f"-s {paasta_cluster}" if "prod" in paasta_cluster else f'-e {paasta_cluster.split("-")[1]}'
except IndexError:
location_selector = f"-s {paasta_cluster}"

if use_s3_reader:
location_selector = f"-s {get_superregion()}"
else:
try:
location_selector = (
f"-s {paasta_cluster}" if "prod" in paasta_cluster else f'-e {paasta_cluster.split("-")[1]}'
)
except IndexError:
location_selector = f"-s {paasta_cluster}"

command_name = "vector-reader" if use_s3_reader else "scribereader"
truncation_message = (
[
f"This output is truncated. Use this command to view all lines: scribereader {location_selector} {stream_name} --min-date {min_date.date()} --max-date {max_date.date()} | jq --raw-output 'select(.tron_run_number=={int(paasta_logs.run_num)} and .component == \"{component}\") | .message'"
f"This output is truncated. Use this command to view all lines: {command_name} {location_selector} {stream_name} --min-date {min_date.date()} --max-date {max_date.date()} | jq --raw-output 'select(.tron_run_number=={int(paasta_logs.run_num)} and .component == \"{component}\") | .message'"
]
if max_date
else [
f"This output is truncated. Use this command to view all lines: scribereader {location_selector} {stream_name} --min-date {min_date.date()} | jq --raw-output 'select(.tron_run_number=={int(paasta_logs.run_num)} and .component == \"{component}\") | .message'"
f"This output is truncated. Use this command to view all lines: {command_name} {location_selector} {stream_name} --min-date {min_date.date()} | jq --raw-output 'select(.tron_run_number=={int(paasta_logs.run_num)} and .component == \"{component}\") | .message'"
]
)
truncated = truncation_message if paasta_logs.truncated_output else []
Expand Down

0 comments on commit 055e5cc

Please sign in to comment.