Skip to content

Commit

Permalink
[bgpcfgd] improve the log when delete a loopback interface (sonic-net…
Browse files Browse the repository at this point in the history
…#11152)

Why I did it
The bgpcfgd doesn't support deletion of 'zebra set src', if an interface is deleted, the bgpcfgd will drop a warning message. In current implementation, we only care about the loopback0 interface but not others.
To improve the log print to have the key info, which will give the name of the deleted interface. We can ignore it if it is not the loopback0 interface. The application layer should be aware of that update and deletion is not supported, delete or update with a new address of loopback0 could cause issue, this log can give enough info to root cause the issue.

How I did it
How to verify it
  • Loading branch information
StormLiangMS authored Jul 29, 2022
1 parent 526cd92 commit 8d37dd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/sonic-bgpcfgd/bgpcfgd/managers_setsrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ def set_handler(self, key, data):
def del_handler(self, key):
""" Implementation of 'DEL' command for this class """
self.directory.remove(self.db_name, self.table_name, key)
log_warn("Delete command is not supported for 'zebra set src' templates")
log_warn("Delete key '%s' is not supported for 'zebra set src' templates" % str(key))
5 changes: 3 additions & 2 deletions src/sonic-bgpcfgd/tests/test_setsrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ def test_set_handler_invalid_ip(mocked_log_err):
@patch('bgpcfgd.managers_setsrc.log_warn')
def test_del_handler(mocked_log_warn):
m = constructor()
m.del_handler("Loopback0|10.1.0.32/32")
mocked_log_warn.assert_called_with("Delete command is not supported for 'zebra set src' templates")
del_key = "Loopback0|10.1.0.32/32"
m.del_handler(del_key)
mocked_log_warn.assert_called_with("Delete key '%s' is not supported for 'zebra set src' templates" % del_key)

0 comments on commit 8d37dd7

Please sign in to comment.