Skip to content

[Feature Request] Add gNMI target prefix support in TargetConnectionProfile for SONiC compatibility #384

@reinaldosaraiva

Description

@reinaldosaraiva

Summary

SONiC switches require the gNMI target field in the SetRequest prefix to be set to OC-YANG for write operations. Currently, TargetConnectionProfile does not expose this field, making SDC incompatible with SONiC gNMI SET operations.

Environment

  • SDC Version: Latest (config-server, data-server)
  • Device: Dell SONiC Enterprise 4.4.1
  • Protocol: gNMI (port 8080, JSON_IETF encoding)
  • Kubernetes: KinD v1.32.0

Problem Description

When using SDC to configure SONiC switches via gNMI, all Config CRDs fail with:

status:
  conditions:
  - reason: Unrecoverable
    message: "runtime error: index out of range [-1]"

After investigation, we discovered that SONiC gNMI requires the -xpath_target OC-YANG parameter for SET operations:

# This WORKS directly on SONiC:
gnmi_set -insecure -username admin -password admin \
  -target_addr 127.0.0.1:8080 \
  -xpath_target OC-YANG \
  -update /openconfig-system:system/config:@./hostname.json

The -xpath_target maps to the target field in the gNMI Path.prefix:

message Path {
  string target = 1;  // <-- This field needs to be configurable
  string origin = 2;
  repeated PathElem elem = 3;
}

Current TargetConnectionProfile Spec

The current TargetConnectionProfile for gNMI does not have a target field:

apiVersion: inv.sdcio.dev/v1alpha1
kind: TargetConnectionProfile
metadata:
  name: gnmi-sonic
  namespace: sdc
spec:
  protocol: gnmi
  port: 8080
  encoding: JSON_IETF
  skipVerify: true
  connectRetry: 30s
  timeout: 30s
  includeNS: true
  # Missing: target or prefixTarget field

Proposed Solution

Add a new field to TargetConnectionProfileSpec for gNMI:

// TargetConnectionProfileSpec
type TargetConnectionProfileSpec struct {
    // ... existing fields ...

    // GNMITarget specifies the target field in gNMI prefix
    // Used by SONiC (OC-YANG) and potentially other vendors
    // +optional
    GNMITarget *string `json:"gnmiTarget,omitempty"`
}

Example usage:

apiVersion: inv.sdcio.dev/v1alpha1
kind: TargetConnectionProfile
metadata:
  name: gnmi-sonic
spec:
  protocol: gnmi
  port: 8080
  encoding: JSON_IETF
  skipVerify: true
  gnmiTarget: "OC-YANG"  # <-- New field

References

Impact

This would enable SDC to work with:

  • Dell SONiC Enterprise
  • SONiC Community Edition
  • Any gNMI implementation requiring custom target prefix

Workaround

Currently using gnmic directly with --target OC-YANG parameter, bypassing SDC.

Additional Context

We successfully validated that SONiC gNMI SET works when using the correct target:

# Test result: SUCCESS
docker exec telemetry gnmi_set -insecure -username admin -password admin \
  -target_addr 127.0.0.1:8080 -xpath_target OC-YANG \
  -update /openconfig-system:system/config:@/tmp/hostname.json

# Response: op:UPDATE  path:openconfig-system:system/config
# Hostname changed from "sonic" to "mgc-spine-1"

The configuration is correct; only the gNMI target prefix is missing.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions