From 47dfaac7ba6b22a59aa2fb654f88f44d1e85f3c8 Mon Sep 17 00:00:00 2001 From: Alex ubuntu vm <alexdecb@yahoo.es> Date: Fri, 17 Nov 2023 12:13:43 +0100 Subject: [PATCH] BUG FIX: Database not updated when node is not present --- operator/src/operator/l2sm-operator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/operator/src/operator/l2sm-operator.py b/operator/src/operator/l2sm-operator.py index 413ab11..0d87886 100644 --- a/operator/src/operator/l2sm-operator.py +++ b/operator/src/operator/l2sm-operator.py @@ -283,13 +283,15 @@ def delete_vn(spec, name, logger, **kwargs): logger.info(f"Error: {response.status_code}") db.close() -#DELETE DATABASE ENTRIES WHEN A NEW L2SM POD IS DELETED (A NEW NODE GETS OUT OF THE CLUSTER) +#DELETE DATABASE ENTRIES WHEN A NEW L2SM SWITCH IS DELETED (A NEW NODE GETS OUT OF THE CLUSTER) @kopf.on.delete('pods.v1', labels={'l2sm-component': 'l2sm-switch'}) def remove_node(body, logger, annotations, **kwargs): db = pymysql.connect(host=databaseIP,user="l2sm",password="l2sm;",db="L2SM") cur = db.cursor() sql = "DELETE FROM interfaces WHERE node = '%s'" % (body['spec']['nodeName']) + switchSql = "DELETE FROM switches WHERE node = '%s'" % (body['spec']['nodeName']) cur.execute(sql) + cur.execute(switchSql) db.commit() db.close() logger.info(f"Node {body['spec']['nodeName']} has been deleted from the cluster") -- GitLab