Skip to content

Commit 45d2eb9

Browse files
Merge branch 'main' into Added_start_time
2 parents 0d8349f + 25b5cf4 commit 45d2eb9

File tree

2 files changed

+46
-10
lines changed

2 files changed

+46
-10
lines changed

constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
PROW_VIEW_URL = "https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs"
22
JOB_LINK_URL= "https://prow.ci.openshift.org/"
3-
RELEASE_URL = "https://ppc64le.ocp.releases.ci.openshift.org/releasestream/4-stable-ppc64le/release/"
3+
STABLE_RELEASE_URL = "https://ppc64le.ocp.releases.ci.openshift.org/releasestream/4-stable-ppc64le/release/"
4+
DEV_PREVIEW_RELEASE_URL = "https://ppc64le.ocp.releases.ci.openshift.org/releasestream/4-dev-preview-ppc64le/release/"
5+
HYPERVISOR_CONNECTION_ERROR = "failed to connect to the hypervisor"

monitor.py

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,29 @@ def fetch_release_date(release):
1717
'''
1818
Returns the created date of release
1919
'''
20-
url = constants.RELEASE_URL + release
20+
2121
try:
22+
url = constants.STABLE_RELEASE_URL + release
2223
response = requests.get(url, verify=False, timeout=15)
24+
if response.status_code == 404:
25+
url = constants.DEV_PREVIEW_RELEASE_URL + release
26+
response = requests.get(url, verify=False, timeout=15)
27+
if response.status_code == 404:
28+
print(f"Failed to get the release page. {response.text}")
29+
sys.exit(1)
2330
if response.status_code == 200:
24-
soup = BeautifulSoup(response.text, 'html.parser')
25-
p_elements = soup.find_all("p")
26-
for p in p_elements:
31+
soup = BeautifulSoup(response.text, 'html.parser')
32+
p_elements = soup.find_all("p")
33+
for p in p_elements:
2734
p_ele = p.string
2835
if p_ele:
2936
if "Created:" in p_ele:
3037
start_date = p_ele.split(" ")[1]+" "+p_ele.split(" ")[2]
3138
break
32-
return start_date
33-
else:
34-
return "failed to get the release page"
39+
return start_date
40+
else:
41+
print(f"Failed to get the release page. {response.text}")
42+
sys.exit(1)
3543
except requests.Timeout as e:
3644
return "Request timed out"
3745
except requests.RequestException as e:
@@ -398,6 +406,23 @@ def check_if_gather_libvirt_dir_exists(spy_link,job_type):
398406
return "Request timed out"
399407
except requests.RequestException:
400408
return "Error while sending request to url"
409+
410+
#This is to check for hypervisor error
411+
def check_hypervisor_error(spy_link):
412+
build_log_url = constants.PROW_VIEW_URL + spy_link[8:] + '/build-log.txt'
413+
try:
414+
response = requests.get(build_log_url, verify=False, timeout=15)
415+
hypervisor_re = re.compile(constants.HYPERVISOR_CONNECTION_ERROR)
416+
hypervisor_re_match = hypervisor_re.search(response.text)
417+
if hypervisor_re_match is not None:
418+
return True
419+
else:
420+
return False
421+
except requests.Timeout:
422+
return "Request timed out"
423+
except requests.RequestException:
424+
return "Error while sending request to url"
425+
401426

402427
#This is a fix to check for sensitive information expose error.
403428
def check_if_sensitive_info_exposed(spy_link):
@@ -1258,6 +1283,10 @@ def get_brief_job_info(build_list,prow_ci_name,zone=None):
12581283
job_dict["Test result"] = str(e2e_fail_test_count) + " testcases failed"
12591284
else:
12601285
job_dict["Test result"] = "Failed to get Test summary"
1286+
else:
1287+
hypervisor_error_status = check_hypervisor_error(build)
1288+
if hypervisor_error_status:
1289+
job_dict["Test result"] = constants.HYPERVISOR_CONNECTION_ERROR
12611290
summary_list.append(job_dict)
12621291
return summary_list
12631292

@@ -1319,7 +1348,11 @@ def get_detailed_job_info(build_list,prow_ci_name,zone=None):
13191348
print("Lease Quota-", lease)
13201349
node_status = get_node_status(build)
13211350
print(node_status)
1322-
check_node_crash(build)
1351+
hypervisor_error_status = check_hypervisor_error(build)
1352+
if hypervisor_error_status:
1353+
print("Cluster Creation Failed."+constants.HYPERVISOR_CONNECTION_ERROR)
1354+
else :
1355+
check_node_crash(build)
13231356

13241357
if cluster_status == 'SUCCESS':
13251358
deploy_count += 1
@@ -1331,8 +1364,9 @@ def get_detailed_job_info(build_list,prow_ci_name,zone=None):
13311364

13321365
elif cluster_status == 'FAILURE':
13331366
print("Cluster Creation Failed")
1367+
13341368

1335-
elif cluster_status == 'ERROR':
1369+
elif cluster_status == 'ERROR' and not hypervisor_error_status :
13361370
print('Unable to get cluster status please check prowCI UI ')
13371371
else:
13381372
print(build_status)

0 commit comments

Comments
 (0)