Skip to content

Commit

Permalink
Merge pull request juju#11768 from ycliuhw/fix/CAAS-CI-LB-GET
Browse files Browse the repository at this point in the history
juju#11768

## Description of change

move `svc` ingress address getter from CAAS test to provider level because different provider might have the address in different field.
  • Loading branch information
jujubot authored Jun 29, 2020
2 parents 021d522 + cab0175 commit 3eee59f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 1 addition & 5 deletions acceptancetests/assess_caas_deploy_charms.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ def get_app_endpoint(caas_client, model_name, app_name, svc_type, timeout=180):
if svc_type == 'LoadBalancer':
for remaining in until_timeout(timeout):
try:
lb_addr = json.loads(
caas_client.kubectl(
'-n', model_name, 'get', 'svc', app_name, '-o', 'json'
)
)['status']['loadBalancer']['ingress'][0]['ip']
lb_addr = caas_client.get_lb_svc_address(app_name, model_name)
if lb_addr:
log.info('load balancer addr for %s is %s' % (app_name, lb_addr))
return lb_addr
Expand Down
5 changes: 5 additions & 0 deletions acceptancetests/jujupy/k8s_provider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ def get_first_worker_ip(self):
logger.debug("trying to get first worker node IP, nodes are -> \n%s", pformat(nodes))
return self._node_address_getter(nodes['items'][0])

def get_lb_svc_address(self, svc_name, namespace):
return json.loads(
self.kubectl('-n', namespace, 'get', 'svc', svc_name, '-o', 'json')
)['status']['loadBalancer']['ingress'][0]['ip']

def ensure_cleanup(self):
controller_uuid = self.client.get_controller_uuid()
namespaces = json.loads(
Expand Down
5 changes: 5 additions & 0 deletions acceptancetests/jujupy/k8s_provider/eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ def list_clusters(self, region):
self.eksctl('get', 'cluster', '--region', region, '-o', 'json'),
)

def get_lb_svc_address(self, svc_name, namespace):
return json.loads(
self.kubectl('-n', namespace, 'get', 'svc', svc_name, '-o', 'json')
)['status']['loadBalancer']['ingress'][0]['hostname']

def _ensure_kube_dir(self):
logger.info("Writing kubeconfig to %s" % self.kube_config_path)
self.eksctl(
Expand Down

0 comments on commit 3eee59f

Please sign in to comment.