Skip to content

Commit 1ae65e3

Browse files
Adding cleanup for BGP_PEER_CONFIGURED_TABLE when config reload is done (#4034)
What I did When config reload is done, BGP_PEER_CONFIGURED_TABLE is not cleared of pervious entries of BGP peers. Added logic to clean that up during config reload How I did it Connected to state db and cleared up all keys starting with BGP_PEER_CONFIGURED_TABLE|* How to verify it delete a peer from config_db.json and perform config reload. Peer should be deleted from state db table BGP_PEER_CONFIGURED_TABLE
1 parent e6a909e commit 1ae65e3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

config/main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,13 @@ def delete_transceiver_tables():
15751575
state_db.delete_all_by_pattern(state_db.STATE_DB, table + state_db_del_pattern)
15761576

15771577

1578+
def delete_bgp_peer_table():
1579+
# Delete all entries in BGP_PEER_CONFIGURED_TABLE in state db.
1580+
state_db = SonicV2Connector(use_unix_socket_path=True)
1581+
state_db.connect(state_db.STATE_DB, False)
1582+
state_db.delete_all_by_pattern(state_db.STATE_DB, "BGP_PEER_CONFIGURED_TABLE|*")
1583+
1584+
15781585
def migrate_db_to_lastest(namespace=DEFAULT_NAMESPACE):
15791586
# Migrate DB contents to latest version
15801587
db_migrator = '/usr/local/bin/db_migrator.py'
@@ -2210,6 +2217,7 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, force, file_form
22102217

22112218
client, config_db = flush_configdb(namespace)
22122219
delete_transceiver_tables()
2220+
delete_bgp_peer_table()
22132221

22142222
if load_sysinfo:
22152223
if namespace is DEFAULT_NAMESPACE:
@@ -2347,6 +2355,7 @@ def load_minigraph(db, no_service_restart, traffic_shift_away, override_config,
23472355
if not no_service_restart:
23482356
log.log_notice("'load_minigraph' stopping services...")
23492357
delete_transceiver_tables()
2358+
delete_bgp_peer_table()
23502359
_stop_services()
23512360

23522361
# For Single Asic platform the namespace list has the empty string

0 commit comments

Comments
 (0)