flush logs
This commit is contained in:
@@ -23,7 +23,9 @@ def update_service_annotation(external_ip):
|
|||||||
current_annotation = service.metadata.annotations.get(ANNOTATION_KEY)
|
current_annotation = service.metadata.annotations.get(ANNOTATION_KEY)
|
||||||
ipam_address = service.spec.load_balancer_ip
|
ipam_address = service.spec.load_balancer_ip
|
||||||
if ipam_address:
|
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})
|
target_annotation = ",".join({ipam_address, external_ip})
|
||||||
else:
|
else:
|
||||||
target_annotation = external_ip
|
target_annotation = external_ip
|
||||||
@@ -32,7 +34,8 @@ def update_service_annotation(external_ip):
|
|||||||
body = {"metadata": {"annotations": {ANNOTATION_KEY: target_annotation}}}
|
body = {"metadata": {"annotations": {ANNOTATION_KEY: target_annotation}}}
|
||||||
v1.patch_namespaced_service(SERVICE_NAME, NAMESPACE, body)
|
v1.patch_namespaced_service(SERVICE_NAME, NAMESPACE, body)
|
||||||
print(
|
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
|
break
|
||||||
|
|
||||||
if external_ip:
|
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)
|
update_service_annotation(external_ip)
|
||||||
|
|
||||||
except client.exceptions.ApiException as e:
|
except client.exceptions.ApiException as e:
|
||||||
print(f"API Exception: {e}")
|
print(f"API Exception: {e}", flush=True)
|
||||||
time.sleep(5) # Wait before retrying
|
time.sleep(5) # Wait before retrying
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Unexpected error: {e}")
|
print(f"Unexpected error: {e}", flush=True)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user