Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle exception to avoid lldp_syncd crash #65

Merged
merged 3 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lldp_syncd/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ def source_update(self):
logger.debug("Invoking lldpcli with: {}".format(cmd_local))

lldp_json = self._scrap_output(cmd)
if lldp_json is None:
return None
lldp_json['lldp_loc_chassis'] = self._scrap_output(cmd_local)

return lldp_json
Expand Down
41 changes: 40 additions & 1 deletion tests/test_lldpSyncDaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,43 @@ def test_changed_deleted_interface(self):
else:
jo[k] = db.get_all(db.APPL_DB, k)
if 'LLDP_ENTRY_TABLE:Ethernet104' in jo:
self.fail("After removing Ethernet104, it is still found in APPL_DB!")
self.fail("After removing Ethernet104, it is still found in APPL_DB!")

@mock.patch('subprocess.check_output')
def test_invalid_chassis_name(self, mock_check_output):
# mock the invalid chassis name
mock_check_output.return_value = '''
{
"local-chassis": {
"chassis": {
"chassis_name\1": {
"id": {
"type": "mac",
"value": "aa:bb:cc:dd:ee:ff"
},
"descr": "SONiC Software Version: SONiC.20230531.22",
"capability": [
{
"type": "Bridge",
"enabled": true
},
{
"type": "Router",
"enabled": true
},
{
"type": "Wlan",
"enabled": false
},
{
"type": "Station",
"enabled": false
}
]
}
}
}
}
'''
result = self.daemon.source_update()
self.assertIsNone(result)
Loading