Update EP LBaaS state annotation check
In some cases (depends on pod creation time) K8S-Endpoints will be created in two steps. The first step will be the creation of EP with a single pod, and the next step will be updating EP with the second pod. For this specific case, the Kuryr controller's EP handler will be called (and of course annotate LBaaS state) twice. To handle this case properly, we need to verify not just Kuryr controller annotates LBaaS state In EP but that Kuryr controller annotates all members(pods). I assume that this change should resolve the issue where we got in some of the tests (got reply only from a single pod). Change-Id: I9cfcb20112c7e4b075741e548d2edf7fc395c22f
This commit is contained in:
parent
3ae7eef13e
commit
3532be1e96
|
@ -380,7 +380,7 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
|
|||
if get_ip:
|
||||
cls.service_ip = cls.get_service_ip(
|
||||
service_name, spec_type=spec_type, namespace=namespace)
|
||||
cls.verify_lbaas_endpoints_configured(service_name)
|
||||
cls.verify_lbaas_endpoints_configured(service_name, pod_num)
|
||||
cls.service_name = service_name
|
||||
cls.wait_service_status(
|
||||
cls.service_ip, CONF.kuryr_kubernetes.lb_build_timeout)
|
||||
|
@ -513,14 +513,16 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
|
|||
predicate(self, resps)
|
||||
|
||||
@classmethod
|
||||
def verify_lbaas_endpoints_configured(cls, ep_name, namespace='default'):
|
||||
def verify_lbaas_endpoints_configured(cls, ep_name, pod_num,
|
||||
namespace='default'):
|
||||
cls._verify_endpoints_annotation(
|
||||
ep_name=ep_name, ann_string=K8S_ANNOTATION_LBAAS_STATE,
|
||||
poll_interval=10)
|
||||
poll_interval=10, pod_num=pod_num)
|
||||
|
||||
@classmethod
|
||||
def _verify_endpoints_annotation(cls, ep_name, ann_string,
|
||||
poll_interval=1, namespace='default'):
|
||||
poll_interval=1, namespace='default',
|
||||
pod_num=None):
|
||||
LOG.info("Look for %s string in ep=%s annotation ",
|
||||
ann_string, ep_name)
|
||||
# wait until endpoint annotation created
|
||||
|
@ -530,7 +532,23 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
|
|||
ep_name, namespace)
|
||||
annotations = ep.metadata.annotations
|
||||
try:
|
||||
json.loads(annotations[ann_string])
|
||||
annotation = json.loads(annotations[ann_string])
|
||||
# NOTE(yboaron): In some cases (depends on pod
|
||||
# creation time) K8S-Endpoints will be created in two steps.
|
||||
# The first step will be the creation of EP with a single pod,
|
||||
# and the next step will be updating EP with the second pod.
|
||||
# To handle this case properly, we need to verify not just
|
||||
# Kuryr controller annotates LBaaS state In EP but that Kuryr
|
||||
# controller annotates all members(pods).
|
||||
if (ann_string == K8S_ANNOTATION_LBAAS_STATE and
|
||||
pod_num is not None):
|
||||
members_num = len(annotation.get('versioned_object.data')
|
||||
.get('members'))
|
||||
if pod_num != members_num:
|
||||
LOG.info("Found %s string in ep=%s annotation but "
|
||||
"members num(%d) != pod_num(%d)",
|
||||
ann_string, ep_name, members_num, pod_num)
|
||||
continue
|
||||
LOG.info("Found %s string in ep=%s annotation ",
|
||||
ann_string, ep_name)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue