Skip to content

[hft] Target per-key path in JSON Patch ops to avoid wiping the table#4663

Open
DavidZagury wants to merge 1 commit into
sonic-net:masterfrom
DavidZagury:master_hft_mixed_mode
Open

[hft] Target per-key path in JSON Patch ops to avoid wiping the table#4663
DavidZagury wants to merge 1 commit into
sonic-net:masterfrom
DavidZagury:master_hft_mixed_mode

Conversation

@DavidZagury

Copy link
Copy Markdown
Contributor

What I did

Fix config hft add profile / config hft add group so the emitted
JSON Patch no longer wipes pre-existing rows in
HIGH_FREQUENCY_TELEMETRY_PROFILE /
HIGH_FREQUENCY_TELEMETRY_GROUP.

How I did it

Changed _build_profile_patch and _build_group_patch in
config/hft.py to target the row's per-key path
(/HIGH_FREQUENCY_TELEMETRY_PROFILE/ or
/HIGH_FREQUENCY_TELEMETRY_GROUP/|) with the row's
attributes as the value, instead of the table-level path with a
single-entry value dict. This matches what _build_stream_state_patch
and the build*_remove_patch helpers in the same file already do.

Updated the two CLI unit tests in tests/config_hft_test.py that
asserted the old patch shape.

No CLI surface or CONFIG_DB schema change.

How to verify it

  • pytest tests/config_hft_test.py — both updated assertions pass.
  • Manual smoke against a running SONiC switch:

config hft add profile P --poll_interval 10000
config hft add group P --group_type PORT --object_names Ethernet0
config hft add group P --group_type QUEUE --object_names Ethernet0
sonic-cfggen -d -v 'HIGH_FREQUENCY_TELEMETRY_GROUP'

  • After the fix both P|PORT and P|QUEUE are present; before the fix
    only P|QUEUE remained.

Previous command output (if the output of a command-line utility has changed)

N/A - no user-facing CLI output change.

New command output (if the output of a command-line utility has changed)

N/A - no user-facing CLI output change.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

What I did
Change _build_profile_patch and _build_group_patch so they emit a
JSON Patch "add" at the row's per-key path
(/HIGH_FREQUENCY_TELEMETRY_PROFILE/<name> or
/HIGH_FREQUENCY_TELEMETRY_GROUP/<profile>|<group>) instead of an "add"
at the table-level path with a value dict containing only the new
row. Update the two CLI unit tests that asserted the old shape.

Why I did it
Per RFC 6902 section 4.1 an "add" at an existing object member
replaces that member's value, so today's
"add /HIGH_FREQUENCY_TELEMETRY_GROUP {<new>: {...}}"
overwrites the entire table value with just the new row, silently
deleting every other group already present. Concretely:

  config hft add group P --group_type PORT  ...   # table = {P|PORT}
  config hft add group P --group_type QUEUE ...   # table = {P|QUEUE}, P|PORT gone

The orchagent observes PORT disappearing and tears down its TAM
resources via clearGroup. In MIXED tam_tel_type mode those resources
are shared with QUEUE, so the second add ends up recreating them.
Targeting the per-key path makes the patch a true insert
(or a row-level replace when re-adding the same row), matching what
_build_stream_state_patch and the _build_*_remove_patch helpers in
this file already do. No CLI surface or CONFIG_DB schema change.

Signed-off-by: david.zagury <davidza@nvidia.com>
@DavidZagury
DavidZagury force-pushed the master_hft_mixed_mode branch from 0293626 to 24b5da1 Compare July 2, 2026 22:50
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

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.

3 participants