Skip to content

Fix gNMI GET failure for SAI log levels in logger#215

Open
rakshitha-marvell wants to merge 2 commits into
sonic-net:masterfrom
rakshitha-marvell:gnmi_union_with_multi_enum
Open

Fix gNMI GET failure for SAI log levels in logger#215
rakshitha-marvell wants to merge 2 commits into
sonic-net:masterfrom
rakshitha-marvell:gnmi_union_with_multi_enum

Conversation

@rakshitha-marvell

@rakshitha-marvell rakshitha-marvell commented May 7, 2026

Copy link
Copy Markdown
Contributor

Fixes : sonic-net/sonic-gnmi#668

Problem:
SONiC sonic-logger.yang defines LOGLEVEL as a union of two enum typedefs (swss_loglevel and sai_loglevel). During gNMI GET, values like SAI_LOG_LEVEL_DEBUG fail to unmarshal, as the generated ocbinds.go contains only swss enum values and misses SAI enums.

RCA:

  1. In goyang, enum typedefs with identical structure are treated as equal (Name field is ignored), so sai_loglevel gets dropped during deduplication.

  2. In ygot:

    • Multiple enum typedefs in a union are not handled correctly.
    • Even if processed, both enums start from 0, causing value conflicts.

Fix:

  • goyang: Include Name in equality check to avoid dropping distinct typedefs.
  • ygot:
    • Allow multiple enum typedefs in union.
    • Merge enums by rebasing values of the second typedef to avoid conflicts.

Problem:
SONiC sonic-logger.yang defines LOGLEVEL as a union of two enum typedefs
(swss_loglevel and sai_loglevel). During gNMI GET, values like
SAI_LOG_LEVEL_DEBUG fail to unmarshal, as the generated ocbinds.go
contains only swss enum values and misses SAI enums.

RCA:
1. In goyang, enum typedefs with identical structure are treated as equal
   (Name field is ignored), so sai_loglevel gets dropped during deduplication.

2. In ygot:
   - Multiple enum typedefs in a union are not handled correctly.
   - Even if processed, both enums start from 0, causing value conflicts.

Fix:
- goyang: Include Name in equality check to avoid dropping distinct typedefs.
- ygot:
  - Allow multiple enum typedefs in union.
  - Merge enums by rebasing values of the second typedef to avoid conflicts.

Impact:
- Both swss and SAI enum values are generated correctly.
- gNMI GET works for all log levels.

Note:
Upgrading ygot/goyang was avoided due to compatibility issues with existing
patches. A minimal patch approach was used instead.
Signed-off-by: Rakshitha SK <rsk@marvell.com>
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

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

@mssonicbld

Copy link
Copy Markdown

/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.

[BUG] Missing SAI log level enumerations in gNMI ocbinds due to union type deduplication in goyang

2 participants