From 1880f8ce54ba19340530547bebe31a68143cecff Mon Sep 17 00:00:00 2001 From: Malar Invention Date: Fri, 1 Nov 2024 11:55:43 +0530 Subject: [PATCH] flush logs --- node_external_ip_controller.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/node_external_ip_controller.py b/node_external_ip_controller.py index 9b484f9..ec48353 100644 --- a/node_external_ip_controller.py +++ b/node_external_ip_controller.py @@ -23,7 +23,9 @@ def update_service_annotation(external_ip): current_annotation = service.metadata.annotations.get(ANNOTATION_KEY) ipam_address = service.spec.load_balancer_ip if ipam_address: - print(f"service {SERVICE_NAME} has existing ipam IP: {ipam_address}") + print( + f"service {SERVICE_NAME} has existing ipam IP: {ipam_address}", flush=True + ) target_annotation = ",".join({ipam_address, external_ip}) else: target_annotation = external_ip @@ -32,7 +34,8 @@ def update_service_annotation(external_ip): body = {"metadata": {"annotations": {ANNOTATION_KEY: target_annotation}}} v1.patch_namespaced_service(SERVICE_NAME, NAMESPACE, body) print( - f"Updated service {SERVICE_NAME} with new external IPs: {target_annotation}" + f"Updated service {SERVICE_NAME} with new external IPs: {target_annotation}", + flush=True, ) @@ -54,15 +57,18 @@ def main(): break if external_ip: - print(f"Detected external IP {external_ip} for node {node_name}") + print( + f"Detected external IP {external_ip} for node {node_name}", + flush=True, + ) update_service_annotation(external_ip) except client.exceptions.ApiException as e: - print(f"API Exception: {e}") + print(f"API Exception: {e}", flush=True) time.sleep(5) # Wait before retrying except Exception as e: - print(f"Unexpected error: {e}") + print(f"Unexpected error: {e}", flush=True) time.sleep(5)