Skip to content

Commit c111985

Browse files
Shilpa-GokulKeerthanaAP
authored andcommitted
Add support to fetch a single success job by setting a flag
1 parent 338a6d5 commit c111985

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CI_JobHistory.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ def main():
317317
parser.add_argument('--job_type', default='p', choices=['p','z','pa'], help= 'Specify the CI job type (Power(p) or s390x(z) or Power Auxillary(pa)), default is p')
318318
parser.add_argument('--filter',default='All',type= lambda arg:arg.split(','), help='Specify the filter string to fetch jobs (Example heavy build / libvirt / powervs / upgrade / 4.14 / 4.15 / 4.16 / 4.17/ 4.18 )')
319319
parser.add_argument('--job_install_status',default='All',choices=['failure','success'],help='Specify the desired job install status to filter the jobs accordingly')
320+
parser.add_argument('--fetch_one_success_job',action='store_true', help='Set this flag to check job runs until one success job is found')
320321
args = parser.parse_args()
321322
filter=args.filter
322323

@@ -420,7 +421,7 @@ def main():
420421
if option == '7':
421422
for ci_name,ci_link in ci_list.items():
422423
spy_links = monitor.get_jobs_with_date(ci_link,start_date,end_date)
423-
monitor.get_detailed_job_info(spy_links,ci_name,zone=args.zone)
424+
monitor.get_detailed_job_info(spy_links,ci_name,zone=args.zone,fetch_one_success_job=args.fetch_one_success_job)
424425
monitor.final_job_list = []
425426

426427
if __name__ == "__main__":

monitor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,6 @@ def get_jobs_with_date(prowci_url,start_date,end_date):
11431143
if end_date <= job_time <= start_date and ele["Result"] != "PENDING" :
11441144
job_log_path = ele["SpyglassLink"]
11451145
final_job_list.append(job_log_path)
1146-
11471146
#build match extracts the next page spylink
11481147
build_regex = r"/([^/?]+)\?.+"
11491148
build_match = re.search(build_regex,next_link)
@@ -1296,7 +1295,8 @@ def get_brief_job_info(build_list,prow_ci_name,zone=None,job_filter='All'):
12961295
summary_list.append(job_dict)
12971296
return summary_list
12981297

1299-
def get_detailed_job_info(build_list, prow_ci_name, zone=None, job_filter="all"):
1298+
def get_detailed_job_info(build_list,prow_ci_name,zone=None,fetch_one_success_job=False, job_filter="all"):
1299+
13001300
"""
13011301
Prints detailed information of all the jobs.
13021302
@@ -1358,7 +1358,9 @@ def get_detailed_job_info(build_list, prow_ci_name, zone=None, job_filter="all")
13581358
print("Lease Quota-", lease)
13591359
check_node_crash(build)
13601360
print("Build Passed")
1361-
1361+
if fetch_one_success_job == True:
1362+
print("Found a passed job, hence ignoring subsequent jobs")
1363+
break
13621364
elif build_status == 'FAILURE':
13631365
if "sno" not in build:
13641366
print("Lease Quota-", lease)

0 commit comments

Comments
 (0)