Skip to content

Cast workaround for N/A counter values from 202412#1962

Merged
lolyu merged 2 commits into
sonic-net:masterfrom
justin-wong-ce:master_tmpcast
Jul 2, 2026
Merged

Cast workaround for N/A counter values from 202412#1962
lolyu merged 2 commits into
sonic-net:masterfrom
justin-wong-ce:master_tmpcast

Conversation

@justin-wong-ce

Copy link
Copy Markdown
Contributor

Description of PR

Summary:
Casting workaround for N/A counters on management ports on Broadcom platforms. This impacts all hwsku-topo combos that uses management ports (including TH5).

Casting from:
Azure/sonic-sairedis.msft#69

Proper fix under review at:
master: #1774
202511: #1862
202605: #1956
Fixes #1753 (temporary fix)

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation update
  • Test improvement

Approach

What is the motivation for this PR?

To fix N/A counters on management ports on Broadcom platforms.

Work item tracking
  • Microsoft ADO (number only):

How did you do it?

Temporarily fill in 0 values for counters that are supported in the usual interfaces but not supported in the management ports.

How did you verify/test it?

show interface counters no longer show N/A counters.

Any platform specific information?

Broadcom only.

Documentation

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

lolyu
lolyu previously approved these changes Jul 1, 2026
@justin-wong-ce

Copy link
Copy Markdown
Contributor Author

Mirroring my reply from direct cast PR to 202605 (#1955 (comment)):

@StormLiangMS , regarding your concerns:

I have one concern before this merges: the PR description scopes the fix to Broadcom management-port N/A counters, but the implementation changes generic FlexCounter behavior. In the single-counter path, any collectData() failure now publishes zero-valued counters to COUNTERS_DB, which can mask real SAI read/clear failures on normal objects and makes unsupported/error/true-zero indistinguishable.

I agree that there is a risk where failures are masked away - this is precisely why this was a temporary workaround limited to specific branches. This is a compromise that has been acknowledged when this temporary workaround is done for the 202412 and 202505 branch. Counter values also cannot go negative as unsigned ints are used for its storage, and anything not a number will cause issues in testing (i.e. N/A). So the only way to make the value appear as a number wihle making sense is to set it to 0.

Could you either scope the zero-fill to the known Broadcom management-port unsupported-counter case, or confirm why it is safe for all single-counter FlexCounter failures on 202605?

The existing FlexCounter implementation is unable to distinguish between ports - there is no notion of multiple ports where all ports are treated as the same. This is precisely why the full fix is needed fast.
Different topo/hwskus will have different number of interfaces, and interfaces are referenced by VID, which is generated during runtime. Ordering of interfaces in the vector of VIDs is also not garunteed to match the port/lane numbering of the switch. This means there is no good way to check for a port's type without making SAI calls and comparing an interface's counter support with another, which you may notice is similar to the full fix...

Any sort of check on interfaces will involve so many parts that it will either be extremely inperformant or become the full fix itself.

One minor thing as well: the new SWSS_LOG_INFO messages use 0x%x for rid/vid; these are sai_object_id_t-sized values, so please use PRIx64 or sai_serialize_object_id() like nearby logs to avoid truncated IDs.

Will do.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@StormLiangMS StormLiangMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@lolyu lolyu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread syncd/FlexCounter.cpp Outdated
Comment thread syncd/FlexCounter.cpp Outdated
@justin-wong-ce

Copy link
Copy Markdown
Contributor Author

/azpw run

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1153496:

✅Stage BuildTrixie:

  • Job amd64: retried.

✅Stage Test:

  • Job vstest: retried.

@justin-wong-ce

Copy link
Copy Markdown
Contributor Author

/azpw retry

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1153496:

✅Stage BuildTrixie:

  • Job amd64: retried.

@StormLiangMS

Copy link
Copy Markdown
Contributor

/azpw retry

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1153496:

✅Stage Test:

  • Job vstest: retried.

@justin-wong-ce

Copy link
Copy Markdown
Contributor Author

/azpw retry

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1153496:

✅Stage Test:

  • Job vstest: retried.

@justin-wong-ce

justin-wong-ce commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

vs tests CI are failing with redis issues in infra @StormLiangMS @lolyu :

../../../../../../usr/lib/python3/dist-packages/redis/connection.py:2
  /usr/lib/python3/dist-packages/redis/connection.py:2: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
    from distutils.version import StrictVersion

test_vnet.py::test_nonflaky_dummy
  /usr/local/lib/python3.10/dist-packages/_pytest/unraisableexception.py:67: PytestUnraisableExceptionWarning: Exception ignored in: <function ApplDbValidator.__del__ at 0x72aff6b10ee0>
  
  Traceback (most recent call last):
    File "/agent/_work/1/s/sonic-swss/tests/conftest.py", line 195, in __del__
      neighbors = self.get_keys(self.NEIGH_TABLE)
    File "/agent/_work/1/s/sonic-swss/tests/dvslib/dvs_database.py", line 138, in get_keys
      table = swsscommon.Table(self.db_connection, table_name)
    File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 3435, in __init__
      _swsscommon.Table_swiginit(self, _swsscommon.new_Table(*args))
  RuntimeError: Unable to connect to redis (unix-socket) - No such file or directory(1): Cannot assign requested address
  
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
---- generated xml file: /agent/_work/1/s/sonic-swss/tests/test_vnet_tr.xml ----
============ 42 passed, 1 skipped, 2 warnings in 1616.38s (0:26:56) ============

##[error]Bash exited with code '123'.
Finishing: Run vs tests

@StormLiangMS

Copy link
Copy Markdown
Contributor

Tracked the recurring VS/DVS CI failure as a sonic-swss infrastructure/test flake:

Failure signature from Azure build 1153496: DVS service readiness timeout with most services STOPPED (start.sh/syncd EXITED), followed by Redis unix-socket cleanup errors and DASH test cascades with docker.errors.NotFound: No such container.

@StormLiangMS

Copy link
Copy Markdown
Contributor

Follow-up on the recurring VS/DVS CI flake: I opened a candidate sonic-swss test-infra fix:

Recent history suggests the VS test job is flaky, not consistently broken. Test / Run vs tests passed in recent Azure.sonic-sairedis builds such as 1153722, 1152093, and 1151868, while the current build 1153496 shows the DVS startup timeout / Docker No such container cascade tracked in sonic-swss#4728.

@lolyu
lolyu force-pushed the master_tmpcast branch from 308fe85 to 2a49a05 Compare July 2, 2026 01:21
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@justin-wong-ce

Copy link
Copy Markdown
Contributor Author

/azpw retry

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1154487:

✅Stage Build:

  • Job amd64: retried.
  • Job amd64: retried.

✅Stage BuildAsan:

  • Job amd64: retried.

@StormLiangMS

Copy link
Copy Markdown
Contributor

/azpw retry

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1154487:

✅Stage Build:

  • Job amd64: retried.
  • Job amd64: retried.

✅Stage BuildAsan:

  • Job amd64: retried.

@justin-wong-ce

Copy link
Copy Markdown
Contributor Author

/azpw retry

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1154487:

✅Stage Build:

  • Job amd64: retried.
  • Job amd64: retried.

✅Stage BuildAsan:

  • Job amd64: retried.

Casting temp-workaround for N/A counters on management ports on 202605.
This impacts all hwsku-topo combos that uses management ports (including
TH5).

Casting from:
Azure/sonic-sairedis.msft#69

Proper fix under review at:
master: sonic-net#1774
202511: sonic-net#1862
202605: Opened soon

Signed-off-by: Justin Wong <jvwong@arista.com>
Signed-off-by: Justin Wong <jvwong@arista.com>
@lolyu
lolyu force-pushed the master_tmpcast branch from 2a49a05 to 6300816 Compare July 2, 2026 10:33
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@lolyu
lolyu merged commit ad128e0 into sonic-net:master Jul 2, 2026
19 checks passed
@mssonicbld

Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202605: #1967

@mssonicbld

Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202605: #1970

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.

No support for interfaces with varying counter support

5 participants