sonic-net / sonic-dbsyncd

Python library for sonic/redis database syncing
Other
6 stars 47 forks source link

accton-as5712-54x: lldp-syncd throws exception from get_sys_capability_list #14

Open nikos-github opened 5 years ago

nikos-github commented 5 years ago

This is seen in the log after the messages reported in https://github.com/Azure/sonic-swss/issues/728.

Nov 3 17:50:40.475838 sonic INFO lldp#supervisord: lldp-syncd Exception in thread LldpSyncDaemon: Nov 3 17:50:40.475999 sonic INFO lldp#supervisord: lldp-syncd Traceback (most recent call last): Nov 3 17:50:40.476080 sonic INFO lldp#supervisord: lldp-syncd File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner Nov 3 17:50:40.476155 sonic INFO lldp#supervisord: lldp-syncd self.run() Nov 3 17:50:40.476227 sonic INFO lldp#supervisord: lldp-syncd File "/usr/local/lib/python2.7/dist-packages/sonic_syncd/interface.py", line 45, in run Nov 3 17:50:40.476301 sonic INFO lldp#supervisord: lldp-syncd parsed_update = self.parse_update(update_obj) Nov 3 17:50:40.476375 sonic INFO lldp#supervisord: lldp-syncd File "/usr/local/lib/python2.7/dist-packages/lldp_syncd/daemon.py", line 250, in parse_update Nov 3 17:50:40.476448 sonic INFO lldp#supervisord: lldp-syncd capability_list = self.get_sys_capability_list(if_attributes) Nov 3 17:50:40.476521 sonic INFO lldp#supervisord: lldp-syncd File "/usr/local/lib/python2.7/dist-packages/lldp_syncd/daemon.py", line 121, in get_sys_capability_list Nov 3 17:50:40.476595 sonic INFO lldp#supervisord: lldp-syncd capability_list = if_attributes['chassis'].values()[0]['capability'] Nov 3 17:50:40.476668 sonic INFO lldp#supervisord: lldp-syncd TypeError: string indices must be integers

chenkelly commented 5 years ago

Current get_sys_capability_list don't consider the system name of remote device is null case. If devices don't configure host name, it will send out LLDPPDU whose System Name TLV is null string. When sonic device learned the remote device, the chassis object of lldp_json does not include system name string. The capability_list does not get successfully by applying current statement, capability_list = if_attributes['chassis'].values()[0]['capability']. We can execute lldpclt command to see the difference.
root@sonic:~# docker exec -it lldp bash root@sonic:/# /usr/sbin/lldpctl -f json [Remote device without system name]

        "chassis": {
           ......
          "capability": [
            {
              "type": "Bridge",
              "enabled": true
            },
            {
              "type": "Router",
              "enabled": true
            }
          ]
        }

[Remote device with system name]

        "chassis": {
          **"ECS4120-28T_device"**: {
              ......
            "capability": [
              {
                "type": "Bridge",
                "enabled": true
              },
              {
                "type": "Router",
                "enabled": true
              }
            ]
          }
        }