logs: add debug logs
parent
e72c1e3c1e
commit
041b45bb94
|
|
@ -13,7 +13,7 @@ SERVICE_REQUEST_TIMEOUT = int(os.getenv("SERVICE_REQUEST_TIMEOUT", 300))
|
|||
NODE_REQUEST_TIMEOUT = int(os.getenv("NODE_REQUEST_TIMEOUT", 30))
|
||||
|
||||
# Logging configuration
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
@ -21,16 +21,22 @@ async def update_service_annotation(v1, service, external_ips):
|
|||
try:
|
||||
service_name = service.metadata.name
|
||||
namespace = service.metadata.namespace
|
||||
logger.debug(f"Fetching service {service_name} in namespace {namespace}")
|
||||
service_obj = await v1.read_namespaced_service(service_name, namespace)
|
||||
|
||||
current_annotation = service_obj.metadata.annotations.get(ANNOTATION_KEY)
|
||||
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:
|
||||
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)
|
||||
logger.info(
|
||||
f"Updated service {service_name} with new external IP: {target_annotation}"
|
||||
)
|
||||
else:
|
||||
logger.debug(f"No update required for service {service_name}")
|
||||
|
||||
except client.exceptions.ApiException as e:
|
||||
logger.error(f"API Exception in update_service_annotation: {e}")
|
||||
|
|
@ -40,19 +46,24 @@ async def watch_nodes(v1, external_ips_update_queue):
|
|||
w = watch.Watch()
|
||||
while True:
|
||||
try:
|
||||
logger.debug("Starting to watch nodes")
|
||||
async for event in w.stream(
|
||||
v1.list_node,
|
||||
label_selector=NODE_LABEL,
|
||||
_request_timeout=NODE_REQUEST_TIMEOUT,
|
||||
):
|
||||
node = event["object"]
|
||||
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 external_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}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue