Skip to content

Add SetBuilder for batched gNMI Set operations#445

Open
felix-kaestner wants to merge 3 commits into
mainfrom
refactor/gnmiext
Open

Add SetBuilder for batched gNMI Set operations#445
felix-kaestner wants to merge 3 commits into
mainfrom
refactor/gnmiext

Conversation

@felix-kaestner

Copy link
Copy Markdown
Contributor

Introduce a SetBuilder type that accumulates update, patch, and delete operations to be executed as a single gNMI Set RPC via the new Client.Do method. This allows atomic multi-operation commits without multiple round-trips to the device.

An optional Limit method controls the maximum number of operations per SetRequest, splitting into multiple RPCs when set.

cp "github.com/felix-kaestner/copy"
"github.com/go-logr/logr"
gpb "github.com/openconfig/gnmi/proto/gnmi"
gnmipb "github.com/openconfig/gnmi/proto/gnmi"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"pb" is the canonical suffix for packages exposing protobuf generated grpc client/server code. ref/ https://pkg.go.dev/google.golang.org/protobuf/types/known

@felix-kaestner
felix-kaestner force-pushed the refactor/gnmiext branch 2 times, most recently from 9b6aad6 to b4aa0bc Compare July 16, 2026 08:41
@github-actions github-actions Bot added size/XXL and removed size/L labels Jul 16, 2026
Introduce a SetBuilder type that accumulates update, patch, and
delete operations to be executed as a single gNMI Set RPC via the
new Client.Do method. This allows atomic multi-operation commits
without multiple round-trips to the device.

An optional Limit method controls the maximum number of operations
per SetRequest, splitting into multiple RPCs when set.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Register three metrics with controller-runtime's metrics registry:
- gnmi_operations_total: per-operation counter with target, rpc,
  operation, path, and status labels
- gnmi_rpc_duration_seconds: histogram of actual gNMI RPC latency
- gnmi_operations_skipped_total: counter for diff-skipped operations

Operation metrics are derived from the SetRequest after the RPC
completes, ensuring the status label reflects the actual outcome.

Add WithTarget option to associate a device address with metrics
for correlating slow-responding devices.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Add go:generate directive to produce a ClientMock using moq with
panic-on-unset and call-tracking resets. Register moq as a Go 1.24+
tool dependency in go.mod.

Replace the hand-rolled MockClient in the IOS-XR provider tests
with the generated gnmiext.ClientMock.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Comment thread internal/provider/cisco/nxos/provider.go Fixed
Comment thread internal/provider/cisco/nxos/provider.go Fixed
@github-actions

Copy link
Copy Markdown

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr 36.07% (ø)
github.com/ironcore-dev/network-operator/internal/transport/gnmiext 59.42% (-30.00%) 💀 💀 💀

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/client.go 87.96% (+0.22%) 216 (+61) 190 (+54) 26 (+7) 👍
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/client_mock.go 0.00% (ø) 126 (+126) 0 126 (+126)
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/metrics.go 100.00% (+100.00%) 1 (+1) 1 (+1) 0 🌟

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr/provider_test.go
  • github.com/ironcore-dev/network-operator/internal/transport/gnmiext/client_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant