Add a cloud provider config option

In case cloud provider is not configured,  Openshift will allocate an
external IP and overwrite status/ingress/IP set by Kuryr-controller.
This patch updates the get_service_ip function, to retrieve the service
external IP based on whether cloud provider is set or not.

Change-Id: I07a771bba7f218ea04c4c4de1dce29ec8c7c9e2f
Depends-On: Iaff9a1f4d3d8972b3e042f5e7b1d3d9c08fe9fc5
This commit is contained in:
Itzik Brown 2019-01-03 11:47:05 +02:00
parent 7f84979019
commit a82c55f7c0
2 changed files with 10 additions and 5 deletions

View File

@ -69,4 +69,6 @@ kuryr_k8s_opts = [
help="Whether or not service UDP tests will be running"),
cfg.BoolOpt("multi_worker_setup", default=False, help="Whether or not we "
"have a multi-worker setup"),
cfg.BoolOpt("cloud_provider", default=False, help="Whether or not a "
"cloud provider is set"),
]

View File

@ -322,10 +322,12 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
time.sleep(5)
service = api.read_namespaced_service(service_name, namespace)
if spec_type == "LoadBalancer":
# NOTE(yboaron): In some cases, OpenShift may overwrite
# LB's IP stored at service.status, we need to make sure that
# this function will return the IP that was annotated by
# Kuryr controller
# In case of a cloud provider not being configured, OpenShift
# allocates an external IP and overwrites the service
# status/ingress/IP set by Kuryr-controller.
# In this case, we should retrieve the external IP from
# Kuryr's annotation.
if service.status.load_balancer.ingress:
endpoints = api.read_namespaced_endpoints(
service_name, namespace)
@ -348,7 +350,8 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
'Annotated pub_ip(%s) != ingress.ip(%s).',
ann_lb_ip,
service.status.load_balancer.ingress[0].ip)
return ann_lb_ip
if not CONF.kuryr_kubernetes.cloud_provider:
return ann_lb_ip
return service.status.load_balancer.ingress[0].ip
elif spec_type == "ClusterIP":
return service.spec.cluster_ip