Compare commits

..

No commits in common. "924c24b16bff1edde14fdad635a028cf5069118b" and "041b45bb94da301d720b9c2c6bef9bdab05e9b46" have entirely different histories.

1 changed files with 7 additions and 23 deletions

View File

@ -25,9 +25,7 @@ async def update_service_annotation(v1, service, external_ips):
service_obj = await v1.read_namespaced_service(service_name, namespace)
current_annotation = service_obj.metadata.annotations.get(ANNOTATION_KEY)
zlan_gateway_ip = service_obj.metadata.labels.get(SERVICE_LABEL_KEY)
logger.debug(f"Zlan Gateway IP: {zlan_gateway_ip}")
target_annotation = ",".join(external_ips) + "," + zlan_gateway_ip
target_annotation = ",".join(external_ips) + "," + ZERO_GATEWAY_IP
logger.debug(f"Current annotation: {current_annotation}")
logger.debug(f"Target annotation: {target_annotation}")
if current_annotation != target_annotation:
@ -46,7 +44,6 @@ async def update_service_annotation(v1, service, external_ips):
async def watch_nodes(v1, external_ips_update_queue):
w = watch.Watch()
external_node_ipset = set()
while True:
try:
logger.debug("Starting to watch nodes")
@ -56,30 +53,17 @@ async def watch_nodes(v1, external_ips_update_queue):
_request_timeout=NODE_REQUEST_TIMEOUT,
):
node = event["object"]
event_type = event["type"]
logger.debug(
f"Received {event_type} event for node: {node.metadata.name}"
)
logger.debug(f"Received event for node: {node.metadata.name}")
external_ips = [
addr.address
for addr in node.status.addresses
if addr.type == "ExternalIP"
]
if event_type in {"ADDED", "MODIFIED"}:
external_node_ipset.update(external_ips)
logger.debug(
f"External IPs for node {node.metadata.name}: {external_ips}"
)
elif event_type == "REMOVED":
for ip in external_ips:
if ip in external_node_ipset:
external_node_ipset.remove(ip)
logger.debug(
f"External IPs for node {node.metadata.name}: {external_ips}"
)
external_node_ips = list(external_node_ipset)
await external_ips_update_queue.put(external_node_ips)
logger.debug(f"Added external IPs to update queue: {external_node_ips}")
logger.debug(
f"External IPs for node {node.metadata.name}: {external_ips}"
)
await external_ips_update_queue.put(external_ips)
logger.debug(f"Added external IPs to update queue: {external_ips}")
except client.exceptions.ApiException as e:
logger.error(f"API Exception in watch_nodes: {e}")