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

[202012] Fix IfHighSpeed UT issue on 202012 #297

Closed
wants to merge 19 commits into from

Conversation

liuh-80
Copy link
Contributor

@liuh-80 liuh-80 commented Oct 13, 2023

Fix IfHighSpeed UT issue on 202012

Work item tracking

Microsoft ADO (number only): 25199873

- What I did
Fix IfHighSpeed UT issue on 202012

- How I did it
Fix UT backport issue by remove unecessary mock data.

- How to verify it
Pass all UT

- Description for the changelog
Fix IfHighSpeed UT issue on 202012

liorghub and others added 19 commits May 12, 2021 19:39
…s not configured. (sonic-net#205)

The ideas of this MIB is to reflect the physical entities and should not be affected by the config_db.json interface configuration.
In the case where the interface does not exist (not configured at all or as a result of user removing the interface from the config_db.json due to port breakout limitation on some platforms), entPhysicalDescr OID should return the transceiver type only and without the interface alias and the extra 'for ' text.

Signed-off-by: liora [email protected]

- What I did
In the case interface not configured but transceiver exist, the transceiver description is only the transceiver type without the extra 'for xxx' text.

- How I did it
Verify if interface is configured. If yes, add to the transceiver type the interface alias. Else, only the transceiver type.

- How to verify it
snmpwalk -v 2c -c public 10.210.24.85 1.3.6.1.2.1.47.1.1.1.1.2 | grep SFP

Signed-off-by: liora <[email protected]>
… if (sonic-net#226)

the hash does not exist in Redis

- What I did
Fixes sonic-net/sonic-buildimage#8140
ref: swsssdk implementation returns None, and the library will be deprecated
libswsscommon implementation returns empty dict
- How I did it
Relax the condition check to accept both representations
- How to verify it
Unit test
Signed-off-by: Qi Luo <[email protected]>
…onic-net#230)

**- What I did**

Fixes [#8293](sonic-net/sonic-buildimage#8293)

**- How I did it**

Accumulated all the older notifications and did act only upon the latest notification discarding the others
updating in update_data. Updating lag oid map in update_data
can cause descrepancy as interface oid map is updated in
reinit_data.
)

**- What I did**
Update snmpagent to use SonicDBConfig from swsscommon.

**- How I did it**
- Update import of SonicDBConfig 
- init_namespace_dbs should return list of all namespace connector classes. Ensure that the list ordering is maintained such that the first element of the list is of the default namespace.
 
**- How to verify it**
Tested on single asic VS; SNMP service starts without any error log.
Execute snmpwalk on one of the OIDs:
admin@vlab-01:~$ docker exec -it snmp snmpwalk -v2c -c public 127.0.0.1 iso.3.6.1.2.1.2.2.1.2
iso.3.6.1.2.1.2.2.1.2.1 = STRING: "fortyGigE0/0"
iso.3.6.1.2.1.2.2.1.2.5 = STRING: "fortyGigE0/4"
iso.3.6.1.2.1.2.2.1.2.9 = STRING: "fortyGigE0/8"
iso.3.6.1.2.1.2.2.1.2.13 = STRING: "fortyGigE0/12"
iso.3.6.1.2.1.2.2.1.2.17 = STRING: "fortyGigE0/16"
iso.3.6.1.2.1.2.2.1.2.21 = STRING: "fortyGigE0/20"
iso.3.6.1.2.1.2.2.1.2.25 = STRING: "fortyGigE0/24"
iso.3.6.1.2.1.2.2.1.2.29 = STRING: "fortyGigE0/28"
..
iso.3.6.1.2.1.2.2.1.2.10000 = STRING: "eth0"

Tested on multi asic VS; SNMP service starts without any error log.
admin@vlab-08:~$ docker exec -it snmp snmpwalk -v2c -c public 127.0.0.1 iso.3.6.1.2.1.2.2.1.2
Execute snmpwalk on one of the OIDs:
iso.3.6.1.2.1.2.2.1.2.1 = STRING: "Ethernet1/1"
iso.3.6.1.2.1.2.2.1.2.5 = STRING: "Ethernet1/2"
iso.3.6.1.2.1.2.2.1.2.9 = STRING: "Ethernet1/3"
iso.3.6.1.2.1.2.2.1.2.13 = STRING: "Ethernet1/4"
iso.3.6.1.2.1.2.2.1.2.17 = STRING: "Ethernet1/5"
iso.3.6.1.2.1.2.2.1.2.21 = STRING: "Ethernet1/6"
iso.3.6.1.2.1.2.2.1.2.25 = STRING: "Ethernet1/7"
iso.3.6.1.2.1.2.2.1.2.29 = STRING: "Ethernet1/8"
iso.3.6.1.2.1.2.2.1.2.1001 = STRING: "PortChannel0001"
..
iso.3.6.1.2.1.2.2.1.2.9000 = STRING: "Eth4-ASIC0"
iso.3.6.1.2.1.2.2.1.2.9004 = STRING: "Eth5-ASIC0"
iso.3.6.1.2.1.2.2.1.2.9008 = STRING: "Eth6-ASIC0"
iso.3.6.1.2.1.2.2.1.2.9012 = STRING: "Eth7-ASIC0"
...
**- Why I did**

An exception on LLDPLocalSystemDataUpdater instance is seen when the LOC_CHASSIS_TABLE does not have either lldp_loc_sys_cap_supported or lldp_loc_sys_cap_enabled fields.

Although this does not affect an functionality, the exception log can be avoided.

```
tgn-sonic-n1-l1 ERR snmp#snmp-subagent [ax_interface] ERROR: MIBUpdater.start() caught an unexpected exception during update_data()#012Traceback (most recent call last):sonic-net#12 File " /usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 37, in start#012 self.reinit_data ()sonic-net#12 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/ieee802_1ab.py", line 129, in reinit_data#012 self.loc_chassis_data['lldp_loc_sys_cap_supported'] = parse_sys_capability(self.loc _chassis_data['lldp_loc_sys_cap_supported'])#012KeyError: 'lldp_loc_sys_cap_supported'
```
In a dynamic environment, it is possible that some of the keys may
disappear between invoking keys() and get_all().

Prevent unnecessary timeout of blocking get_all().
Follow up sonic-net#255.
If route change too fast between keys/hgetall, the original implementation will throw exception and lead to ERR in syslog.
Don't cache the vlan-id if it is not valid from DB

**- What I did**
Avoid caching the vlan-id with invalid value.

**- How I did it**
Add a check in code so if vlan-id is not valid, don't cache it.
It is considered normal that the dependences of FDB_ENTRY are temporarily not available.
**- What I did**
Fix: zero route may have empty nexthop. Improve code robustness.

**- How I did it**

**- How to verify it**
Manual test:
1. manipulate ApplDB default route: remove nexthop field and value
2. recover
3. manipulate ApplDB default route: remove ifname field and value
4. recover

Also add unit test.
… for RFC2863 (sonic-net#279)

**- What I did**
Cherry-pick the required PRs to 202012 Branch to add SNMP VLAN Support.
This is done because the VLAN if index comes in ipNetToMediaPhysAddress (1.3.6.1.2.1.4.22.1.2) but not in ifName 1.3.6.1.2.1.31.1.1.1.1.

**- How I did it**
Cherry-pick below PRs:
sonic-net#218 - Main change
sonic-net#224 - Follow up PR
sonic-net#237 - Follow up PR

**- How to verify it**
Before PR changes:
```
admin@str2-sn3800-02:~$ docker exec -it snmp snmpwalk -v2c -c msft 127.0.0.1 1.3.6.1.2.1.31.1.1.1.1
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "etp1a"
iso.3.6.1.2.1.31.1.1.1.1.3 = STRING: "etp1b"
iso.3.6.1.2.1.31.1.1.1.1.5 = STRING: "etp2a"
iso.3.6.1.2.1.31.1.1.1.1.7 = STRING: "etp2b"
iso.3.6.1.2.1.31.1.1.1.1.9 = STRING: "etp3a"
iso.3.6.1.2.1.31.1.1.1.1.11 = STRING: "etp3b"
..
iso.3.6.1.2.1.31.1.1.1.1.255 = STRING: "etp64b"
iso.3.6.1.2.1.31.1.1.1.1.1101 = STRING: "PortChannel101"
iso.3.6.1.2.1.31.1.1.1.1.1102 = STRING: "PortChannel102"
iso.3.6.1.2.1.31.1.1.1.1.1103 = STRING: "PortChannel103"
iso.3.6.1.2.1.31.1.1.1.1.1104 = STRING: "PortChannel104"
iso.3.6.1.2.1.31.1.1.1.1.10000 = STRING: "eth0"
```

After PR changes; Can see vlan 1000 with ifindex3000:
```
admin@str2-sn3800-02:~$ docker exec -it snmp snmpwalk -v2c -c msft 127.0.0.1 1.3.6.1.2.1.31.1.1.1.1
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "etp1a"
iso.3.6.1.2.1.31.1.1.1.1.3 = STRING: "etp1b"
iso.3.6.1.2.1.31.1.1.1.1.5 = STRING: "etp2a"
iso.3.6.1.2.1.31.1.1.1.1.7 = STRING: "etp2b"
iso.3.6.1.2.1.31.1.1.1.1.9 = STRING: "etp3a"
iso.3.6.1.2.1.31.1.1.1.1.11 = STRING: "etp3b"
..
iso.3.6.1.2.1.31.1.1.1.1.255 = STRING: "etp64b"
iso.3.6.1.2.1.31.1.1.1.1.1101 = STRING: "PortChannel101"
iso.3.6.1.2.1.31.1.1.1.1.1102 = STRING: "PortChannel102"
iso.3.6.1.2.1.31.1.1.1.1.1103 = STRING: "PortChannel103"
iso.3.6.1.2.1.31.1.1.1.1.1104 = STRING: "PortChannel104"
iso.3.6.1.2.1.31.1.1.1.1.3000 = STRING: "Vlan1000"       
iso.3.6.1.2.1.31.1.1.1.1.10000 = STRING: "eth0"
```
UT Passes
… support for RFC2863 (sonic-net#279)" (sonic-net#280)

Reverts sonic-net#279
seeing the below error after PR 279. 
This is causing failure of getting InterfacesMIB data:
docker exec -ti snmp snmpwalk -v2c -c msft 127.0.0.1 1.3.6.1.2.1.2.2.1.1
iso.3.6.1.2.1.2.2.1.1 = No Such Instance currently exists at this OID 
ERR snmp#snmp-subagent [ax_interface] ERROR: MIBUpdater.start() caught an unexpected exception during update_data()#012Traceback (most recent call last):sonic-net#12  File "/usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 43, in start#012    self.update_data()sonic-net#12  File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/ietf/rfc1213.py", line 255, in update_data#012    self.aggregate_counters()sonic-net#12  File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/ietf/rfc1213.py", line 371, in aggregate_counters#012    self.rif_counters[rif_sai_id][rif_counter_name]#012KeyError: 'SAI_ROUTER_INTERFACE_STAT_IN_ERROR_PACKETS'
… missing. (sonic-net#286)

Fix FdbUpdater crash when SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID attribute missing.

#### Work item tracking
Microsoft ADO (number only): 16189251

**- What I did**
Fix FdbUpdater crash when SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID attribute missing.

**- How I did it**
Add try-catch block in rfc3463 FdbUpdater

**- How to verify it**
Manually test.
Pass all UT

**- Description for the changelog**
Fix FdbUpdater crash when SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID attribute missing.
**- What I did**
This change makes SNMP report the correct interface speed for PortChannels instead of defaulting to 40G.

**- How I did it**
Similar to `intfutil`, the code simply sums up the interface speeds of all member ports. The logic for iterating over members is based on `_get_counter`.

**- How to verify it**
- Check `snmpwalk -v 2c -c public <IP> ifHighSpeed`, note that PortChannels are reported as 40G
- Apply the change
- Check again, note that the same speed as in `show interface status` is reported now.

**- Description for the changelog**
Support reporting interface speeds for PortChannels through SNMP
Add unit test for IfHighSpeed with PortChannel with no member ports

#### Work item tracking
Microsoft ADO (number only): 25199873

**- What I did**
Add new UT cover InterfaceMIBUpdater.get_high_speed(), this will fix issue: sonic-net#294

**- How I did it**
Add new UT and mock data to test InterfaceMIBUpdater.get_high_speed() with PortChannel with no member ports

**- How to verify it**
Pass all UT

**- Description for the changelog**
Add unit test of IfHighSpeed with PortChannel with no member ports
@liuh-80 liuh-80 closed this Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants