diff --git a/node_external_ip_controller_async.py b/node_external_ip_controller_async.py index adcbcbf..41f8d50 100644 --- a/node_external_ip_controller_async.py +++ b/node_external_ip_controller_async.py @@ -35,9 +35,7 @@ async def update_service_annotation(v1, service, external_ipset): service_obj = await v1.read_namespaced_service(service_name, namespace) current_annotation = service_obj.metadata.annotations.get(ANNOTATION_KEY, "") - annotated_ips = ( - set(current_annotation.split(",")) if current_annotation else set() - ) + annotated_ipset = set(current_annotation.split(",")) zlan_gateway_ip = service_obj.metadata.labels.get(ZLAN_GATEWAY_IP_KEY) logger.debug(f"Zlan Gateway IP: {zlan_gateway_ip}") @@ -48,9 +46,9 @@ async def update_service_annotation(v1, service, external_ipset): logger.debug( f"Invalid Zlan Gateway IP: {zlan_gateway_ip}, excluding from target annotation" ) - if annotated_ips != external_ipset: - logger.debug(f"Current annotation: {current_annotation}") - logger.debug(f"Target annotation: {target_annotation}") + if annotated_ipset != external_ipset: + logger.debug(f"Current annotation: {current_annotation}: {annotated_ipset}") + logger.debug(f"Target annotation: {target_annotation}: {external_ipset}") body = {"metadata": {"annotations": {ANNOTATION_KEY: target_annotation}}} logger.debug(f"Patching service {service_name} with body: {body}") await v1.patch_namespaced_service(service_name, namespace, body) @@ -101,7 +99,7 @@ async def watch_nodes(v1, external_ips_update_queue): # remove old ip lists before populating while not external_ips_update_queue.empty(): _previous_external_ips = await external_ips_update_queue.get() - await external_ips_update_queue.put(external_node_ipset) + await external_ips_update_queue.put(set(external_node_ips)) logger.debug(f"Added external IPs to update queue: {external_node_ips}") except client.exceptions.ApiException as e: