issue 1715 resend request to kube api for edge labels
@@ -690,6 +690,11 @@ kube_api.session.verify = False
default_edge_region = find_preference(API_GET_DEFAULT_EDGE_REGION_PREF, 'default.edge.region')
edge_region = os.environ.get('CP_EDGE_REGION') or default_edge_region
+# Try to get edge_service_external_ip and edge_service_port for service labels several times before get it from
+# service spec IP and nodePort because it is possible that we will do it while redeploy and label just doesn't
+# applied yet - so we will wait
+edge_kube_service_object = None
+for n in range(NUMBER_OF_RETRIES):
edge_kube_service = Service.objects(kube_api).filter(selector={
EDGE_SVC_ROLE_LABEL: EDGE_SVC_ROLE_LABEL_VALUE, EDGE_SVC_REGION_LABEL: edge_region})
if len(edge_kube_service.response['items']) == 0:
@@ -697,10 +702,6 @@ if len(edge_kube_service.response['items']) == 0:
% (EDGE_SVC_REGION_LABEL, edge_region))
exit(1)
else:
- # Try to get edge_service_external_ip and edge_service_port for service labels several times before get it from
- # service spec IP and nodePort because it is possible that we will do it while redeploy and label just doesn't
- # applied yet - so we will wait
- for n in range(NUMBER_OF_RETRIES):
edge_kube_service_object = edge_kube_service.response['items'][0]
edge_kube_service_object_metadata = edge_kube_service_object['metadata']
@@ -715,9 +716,14 @@ else:
if edge_service_external_ip and edge_service_port:
break
else:
- do_log('Sleep for {} sec and perform kube API call again ({}/{})'.format(SECS_TO_WAIT_BEFORE_RETRY, n + 2, NUMBER_OF_RETRIES))
+ do_log('Sleep for {} sec and perform kube API call again ({}/{})'.format(SECS_TO_WAIT_BEFORE_RETRY, n + 1, NUMBER_OF_RETRIES))
sleep(SECS_TO_WAIT_BEFORE_RETRY)
+if not edge_kube_service_object:
+ do_log('EDGE service is not found by labels: cloud-pipeline/role=EDGE and %s=%s'
+ % (EDGE_SVC_REGION_LABEL, edge_region))
+ exit(1)
+
if not edge_service_external_ip:
do_log('Getting EDGE service host from externalIP')
edge_service_external_ip = edge_kube_service_object['spec']['externalIPs'][0]
