Skip to content
Snippets Groups Projects
Commit 47dfaac7 authored by Alex ubuntu vm's avatar Alex ubuntu vm
Browse files

BUG FIX: Database not updated when node is not present

parent a6128ccb
No related branches found
No related tags found
1 merge request!2repo: added new directory where utils scripts will be
...@@ -283,13 +283,15 @@ def delete_vn(spec, name, logger, **kwargs): ...@@ -283,13 +283,15 @@ def delete_vn(spec, name, logger, **kwargs):
logger.info(f"Error: {response.status_code}") logger.info(f"Error: {response.status_code}")
db.close() 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'}) @kopf.on.delete('pods.v1', labels={'l2sm-component': 'l2sm-switch'})
def remove_node(body, logger, annotations, **kwargs): def remove_node(body, logger, annotations, **kwargs):
db = pymysql.connect(host=databaseIP,user="l2sm",password="l2sm;",db="L2SM") db = pymysql.connect(host=databaseIP,user="l2sm",password="l2sm;",db="L2SM")
cur = db.cursor() cur = db.cursor()
sql = "DELETE FROM interfaces WHERE node = '%s'" % (body['spec']['nodeName']) 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(sql)
cur.execute(switchSql)
db.commit() db.commit()
db.close() db.close()
logger.info(f"Node {body['spec']['nodeName']} has been deleted from the cluster") logger.info(f"Node {body['spec']['nodeName']} has been deleted from the cluster")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment