Skip to content

Commit 4ee9271

Browse files
committed
Add support to fetch a single success job by setting a flag
1 parent 2f79c6c commit 4ee9271

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

CI_JobHistory.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def main():
276276
parser.add_argument('--zone', help='specify the lease/zone', type= lambda arg:arg.split(','))
277277
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')
278278
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 )')
279+
parser.add_argument('--fetch_one_success_job',action='store_true', help='Set this flag to check job runs until one success job is found')
279280
args = parser.parse_args()
280281
filter=args.filter
281282

@@ -372,7 +373,7 @@ def main():
372373
if option == '7':
373374
for ci_name,ci_link in ci_list.items():
374375
spy_links = monitor.get_jobs_with_date(ci_link,start_date,end_date)
375-
monitor.get_detailed_job_info(spy_links,ci_name,zone=args.zone)
376+
monitor.get_detailed_job_info(spy_links,ci_name,zone=args.zone,fetch_one_success_job=args.fetch_one_success_job)
376377
monitor.final_job_list = []
377378

378379
if __name__ == "__main__":

monitor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,6 @@ def get_jobs_with_date(prowci_url,start_date,end_date):
10911091
if end_date <= job_time <= start_date and ele["Result"] != "PENDING" :
10921092
job_log_path = ele["SpyglassLink"]
10931093
final_job_list.append(job_log_path)
1094-
10951094
#build match extracts the next page spylink
10961095
build_regex = r"/([^/?]+)\?.+"
10971096
build_match = re.search(build_regex,next_link)
@@ -1226,7 +1225,7 @@ def get_brief_job_info(build_list,prow_ci_name,zone=None):
12261225
summary_list.append(job_dict)
12271226
return summary_list
12281227

1229-
def get_detailed_job_info(build_list,prow_ci_name,zone=None):
1228+
def get_detailed_job_info(build_list,prow_ci_name,zone=None,fetch_one_success_job=False):
12301229

12311230
"""
12321231
Prints detailed information of all the jobs.
@@ -1275,6 +1274,9 @@ def get_detailed_job_info(build_list,prow_ci_name,zone=None):
12751274
print("Lease Quota-", lease)
12761275
check_node_crash(build)
12771276
print("Build Passed")
1277+
if fetch_one_success_job == True:
1278+
print("Found a passed job, hence ignoring subsequent jobs")
1279+
break
12781280
elif build_status == 'FAILURE':
12791281
cluster_status=cluster_deploy_status(build)
12801282
if "sno" not in build:

0 commit comments

Comments
 (0)