From 9fb4b49bc1b8a1b5b35284b13b7177356bf0951a Mon Sep 17 00:00:00 2001
From: Alex ubuntu vm <alexdecb@yahoo.es>
Date: Fri, 17 Nov 2023 10:59:39 +0100
Subject: [PATCH] BUG FIX: switch ip now is saved correctly in the database,
 using a better trigger for the ip assigning event

---
 operator/src/operator/l2sm-operator.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/operator/src/operator/l2sm-operator.py b/operator/src/operator/l2sm-operator.py
index 70a8b05..413ab11 100644
--- a/operator/src/operator/l2sm-operator.py
+++ b/operator/src/operator/l2sm-operator.py
@@ -100,7 +100,7 @@ def build_db(body, logger, annotations, **kwargs):
     db.close()
     logger.info(f"Node {body['spec']['nodeName']} has been registered in the operator")
 
-@kopf.on.update('pods.v1', labels={'l2sm-component': 'l2sm-switch'})
+@kopf.on.field('pods.v1', labels={'l2sm-component': 'l2sm-switch'}, field='status.podIP')
 def update_db(body, logger, annotations, **kwargs):
     if 'status' in body and 'podIP' in body['status']:
       db = pymysql.connect(host=databaseIP,user="l2sm",password="l2sm;",db="L2SM")
-- 
GitLab