Fallback from V1EndpointPort to CoreV1EndpointPort
For some unknown reason kubernetes==21.7.0 renamed V1EndpointPort to CoreV1EndpointPort while other V1Endpoint* haven't got the prefix. This seems like a bug, but in order to deal with it, this patch adds a fallback to the new name. Change-Id: I4c38c09faba99c8ca56abc0a32bc421011f9b2dd
This commit is contained in:
parent
e1fdcc0a5b
commit
34378686c7
|
@ -817,6 +817,15 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
|
|||
endpoint = cls.k8s_client.V1Endpoints()
|
||||
endpoint.metadata = cls.k8s_client.V1ObjectMeta(name=service_name)
|
||||
# EndpointSubset is a group of addresses with a set of ports
|
||||
try:
|
||||
ports = [cls.k8s_client.V1EndpointPort(
|
||||
name=port_name, port=target_port, protocol=protocol)]
|
||||
except AttributeError:
|
||||
# FIXME(dulek): kubernetes==21.7.0 renamed V1EndpointPort to
|
||||
# CoreV1EndpointPort, probably mistakenly. Bugreport:
|
||||
# https://github.com/kubernetes-client/python/issues/1661
|
||||
ports = [cls.k8s_client.CoreV1EndpointPort(
|
||||
name=port_name, port=target_port, protocol=protocol)]
|
||||
endpoint.subsets = [cls.k8s_client.V1EndpointSubset(
|
||||
addresses=[
|
||||
cls.k8s_client.V1EndpointAddress(
|
||||
|
@ -825,10 +834,7 @@ class BaseKuryrScenarioTest(manager.NetworkScenarioTest):
|
|||
ip=pod_2_ip
|
||||
)
|
||||
],
|
||||
ports=[cls.k8s_client.V1EndpointPort(
|
||||
name=port_name,
|
||||
port=target_port,
|
||||
protocol=protocol)])]
|
||||
ports=ports)]
|
||||
cls.k8s_client.CoreV1Api().create_namespaced_endpoints(
|
||||
namespace=namespace, body=endpoint)
|
||||
cls.endpoint = endpoint
|
||||
|
|
|
@ -250,24 +250,41 @@ class ServiceWOSelectorsNPScenario(base.BaseKuryrScenarioTest):
|
|||
endpoint = self.k8s_client.V1Endpoints()
|
||||
endpoint.metadata = self.k8s_client.V1ObjectMeta(name=service_name)
|
||||
addresses = [self.k8s_client.V1EndpointAddress(ip=server_pod_addr)]
|
||||
try:
|
||||
ports = [self.k8s_client.V1EndpointPort(
|
||||
name=None, port=8080, protocol='TCP')]
|
||||
except AttributeError:
|
||||
# FIXME(dulek): kubernetes==21.7.0 renamed V1EndpointPort to
|
||||
# CoreV1EndpointPort, probably mistakenly. Bugreport:
|
||||
# https://github.com/kubernetes-client/python/issues/1661
|
||||
ports = [self.k8s_client.CoreV1EndpointPort(
|
||||
name=None, port=8080, protocol='TCP')]
|
||||
endpoint.subsets = [self.k8s_client.V1EndpointSubset(
|
||||
addresses=addresses,
|
||||
ports=[self.k8s_client.V1EndpointPort(
|
||||
name=None, port=8080, protocol='TCP')])]
|
||||
ports=ports)]
|
||||
self.k8s_client.CoreV1Api().create_namespaced_endpoints(
|
||||
namespace=server_ns_name, body=endpoint)
|
||||
|
||||
# create another service
|
||||
service2_name, _ = self.create_service(namespace=server_ns_name,
|
||||
pod_label=None)
|
||||
|
||||
# manually create endpoint for the service
|
||||
endpoint = self.k8s_client.V1Endpoints()
|
||||
endpoint.metadata = self.k8s_client.V1ObjectMeta(name=service2_name)
|
||||
addresses = [self.k8s_client.V1EndpointAddress(ip=server2_pod_addr)]
|
||||
try:
|
||||
ports = [self.k8s_client.V1EndpointPort(
|
||||
name=None, port=8080, protocol='TCP')]
|
||||
except AttributeError:
|
||||
# FIXME(dulek): kubernetes==21.7.0 renamed V1EndpointPort to
|
||||
# CoreV1EndpointPort, probably mistakenly. Bugreport:
|
||||
# https://github.com/kubernetes-client/python/issues/1661
|
||||
ports = [self.k8s_client.CoreV1EndpointPort(
|
||||
name=None, port=8080, protocol='TCP')]
|
||||
endpoint.subsets = [self.k8s_client.V1EndpointSubset(
|
||||
addresses=addresses,
|
||||
ports=[self.k8s_client.V1EndpointPort(
|
||||
name=None, port=8080, protocol='TCP')])]
|
||||
ports=ports)]
|
||||
self.k8s_client.CoreV1Api().create_namespaced_endpoints(
|
||||
namespace=server_ns_name, body=endpoint)
|
||||
|
||||
|
|
Loading…
Reference in New Issue