Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
richm committed Jan 21, 2025
1 parent 8be5dd2 commit 8cc3792
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions check_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ def get_errors_from_ansible_log(args, log_url):
log_url,
)
role = match.group(1)
if args.role != ["ALL"] and role not in args.role:
logging.info("Skipping log - role [%s] not in args.role [%s]: [%s]", role, str(args.role), log_url)
return []
test = match.group(2) # unused for now
ansible_version = match.group(3)

Expand Down Expand Up @@ -297,10 +300,14 @@ def get_errors_from_ansible_log(args, log_url):
task_lines.append(line.strip())
if line.startswith("fatal:"):
task_has_fatal = True
elif line.startswith("failed:"):
task_has_fatal = True
elif line.startswith("task path:"):
task_path_match = re.search(r"task path: (.*)", line)
if task_path_match:
task_path = task_path_match.group(1)
elif line.startswith("...ignoring"):
task_has_fatal = False
else:
match = re.search(r"\sfailed=(\d+)\s", line)
if match:
Expand All @@ -311,6 +318,8 @@ def get_errors_from_ansible_log(args, log_url):
len(errors),
total_failed,
)
if total_failed == 0:
errors = []
for error in errors:
error["Fails expected"] = total_failed

Expand Down Expand Up @@ -740,9 +749,15 @@ def print_ansible_errors(args, errors):
sh = gc.create("LSR testing spreadsheet")
# need to show url to new spreadsheet
# and share with given user
worksheet = sh.get_worksheet(0)
else:
sh = gc.open_by_url(args.gspread)
if args.gspread_worksheet_title:
worksheets = [ws for ws in sh.worksheets() if ws.title == args.gspread_worksheet_title]
if worksheets:
worksheet = worksheets[0]
else:
worksheet = sh.add_worksheet(args.gspread_worksheet_title, 1, 1)
else:
worksheet = sh.get_worksheet(0)
worksheet.clear()
values = [headings]
Expand Down Expand Up @@ -869,6 +884,11 @@ def parse_arguments():
default="",
help="update this google spreadsheet - or use NEW to create a new one",
)
parser.add_argument(
"--gspread-worksheet-title",
default="",
help="write to the worksheet with this name - will ensure worksheet exists",
)
parser.add_argument(
"--gspread-creds",
default=os.environ["HOME"] + "/.config/gspread/google_secret.json",
Expand All @@ -887,7 +907,7 @@ def parse_arguments():
help="disable CA cert verify (use requests verify=False)",
)

args = parser.parse_known_args()
args = parser.parse_args()
return args


Expand Down

0 comments on commit 8cc3792

Please sign in to comment.