Skip to content

fix show interface neighbor expected empty issue#2465

Merged
jcaiMR merged 1 commit intosonic-net:masterfrom
jcaiMR:show_device_neighbor_fix
Nov 3, 2022
Merged

fix show interface neighbor expected empty issue#2465
jcaiMR merged 1 commit intosonic-net:masterfrom
jcaiMR:show_device_neighbor_fix

Conversation

@jcaiMR
Copy link
Contributor

@jcaiMR jcaiMR commented Oct 31, 2022

Why I did it

With the commit of sonic-net/sonic-buildimage#11894.
device neighbor metadata in config_db.json changed a little bit when "lo_addr"/"mgmt_addr" are None.

MSFT ADO: 15802924

dfa09cf3-b9f5-4da1-b998-ff750ef6ab12

CLI parse code for "show interface neighbor expected" is not strong enough to handle None case.
It always assume 'lo_addr' and 'mgmt_addr' exists, and will finally cause KeyError, show command will not print the information.

for port in natsorted(list(neighbor_dict.keys())):
            try:
                device = neighbor_dict[port]['name']
                body.append([port,
                             device,
                             neighbor_dict[port]['port'],
                             neighbor_metadata_dict[device]['lo_addr'],
                             neighbor_metadata_dict[device]['mgmt_addr'],
                             neighbor_metadata_dict[device]['type']])
            except KeyError:
                pass

How I did it

After discussion with team, we plan to keep current yang model change, but
add fields check for 'lo_addr', "mgmt_addr", "type"before access it.

How to verify it

"show interface neighbor expected" with fix image

fixes #12301

Copy link
Contributor

@StormLiangMS StormLiangMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants