Skip to content

Fix IndexError and KeyError in test_buffer_pg for ports without 3-4 PG#23312

Open
XuChen-MSFT wants to merge 1 commit intosonic-net:masterfrom
XuChen-MSFT:xuchen3/master/fix-buffer-pg-indexerror
Open

Fix IndexError and KeyError in test_buffer_pg for ports without 3-4 PG#23312
XuChen-MSFT wants to merge 1 commit intosonic-net:masterfrom
XuChen-MSFT:xuchen3/master/fix-buffer-pg-indexerror

Conversation

@XuChen-MSFT
Copy link
Copy Markdown
Contributor

Description of PR

Fix IndexError and KeyError in test_buffer_pg when ports don't have BUFFER_PG|{port}|3-4 configured.

Type of change

  • Bug fix

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Approach

What is the motivation for this PR?

On some HW SKUs (e.g. Arista-7260CX3-C64), certain ports do not have BUFFER_PG|{port}|3-4 configured in CONFIG_DB, and their PG entries may be missing from COUNTERS_PG_NAME_MAP. This causes:

  1. IndexError: list index out of range when accessing profile_in_pg[0] on an empty result (on internal branch with dut_asic.run_redis_cmd())
  2. KeyError when accessing pg_name_map[port:pg] for missing PG entries

Kusto analysis shows this consistently fails on Arista-7260CX3-C64 (bjw2-can-7260-12, bjw-can-7260-8) and occasionally on NH-5010-F-O64.

How did you do it?

  • Added empty check for profile_in_pg before accessing its elements
  • Added key existence check for pg_name_map before dictionary access (both admin-up and admin-down paths)
  • Logs informational message when a PG is not found in COUNTERS_PG_NAME_MAP and skips ASIC_DB check for that PG

How did you verify/test it?

Code review and Kusto analysis of failure patterns.

Any platform specific information?

Affects Arista-7260CX3-C64 and NH-5010-F-O64.

ADO PBI: #37230137

On some HW SKUs (e.g. Arista-7260CX3-C64), certain ports do not have
BUFFER_PG|{port}|3-4 configured in CONFIG_DB, and their PG entries
may be missing from COUNTERS_PG_NAME_MAP. This causes:
1. IndexError when accessing profile_in_pg[0] on empty result
2. KeyError when accessing pg_name_map[port:pg] for missing PGs

Fix by adding:
- Empty check for profile_in_pg before comparison
- Key existence check for pg_name_map before access (both admin-up
  and admin-down paths)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

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.

2 participants