Skip to content

Move gnmiext into new transport package#277

Open
felix-kaestner wants to merge 4 commits intomainfrom
refactor/deviceutil
Open

Move gnmiext into new transport package#277
felix-kaestner wants to merge 4 commits intomainfrom
refactor/deviceutil

Conversation

@felix-kaestner
Copy link
Copy Markdown
Contributor

@felix-kaestner felix-kaestner commented Apr 2, 2026

As we plan to use our gnmiext package also for other provider
implementations of other hardware vendors than Cisco, we now move it
outside of the cisco provider package scope.

With this change we are introducing a new transport package which will
house multiple packages related to transport/protocol specific utilities
and clients.

Additionally a new transport/grpcext package is added which refactors
out all the grpc related code from the deviceutil package and add an
additional interceptor for handling non-retryable grpc error codes.

@felix-kaestner felix-kaestner force-pushed the refactor/deviceutil branch 3 times, most recently from 05aa0ef to 2943ae0 Compare April 2, 2026 22:13
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Merging this branch changes the coverage (1 decrease, 1 increase)

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/internal/deviceutil 38.27% (-2.52%) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr 48.10% (ø)
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos 10.30% (ø)
github.com/ironcore-dev/network-operator/internal/transport/gnmiext 90.62% (+90.62%) 🌟

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/internal/deviceutil/deviceutil.go 38.27% (-2.52%) 81 (+5) 31 50 (+5) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr/intf.go 46.15% (ø) 13 6 7
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr/provider.go 48.48% (ø) 66 32 34
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/acl.go 17.65% (ø) 17 3 14
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/banner.go 20.00% (ø) 10 2 8
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/bgp.go 20.75% (ø) 53 11 42
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/bgw.go 75.00% (ø) 4 3 1
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/cert.go 3.33% (ø) 30 1 29
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/dhcprelay.go 0.00% (ø) 3 0 3
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/dns.go 100.00% (ø) 4 4 0
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/evi.go 42.55% (ø) 47 20 27
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/feat.go 50.00% (ø) 2 1 1
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/grpc.go 13.33% (ø) 15 2 13
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/intf.go 18.44% (ø) 141 26 115
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/isis.go 44.44% (ø) 9 4 5
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/lldp.go 66.67% (ø) 3 2 1
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/ntp.go 50.00% (ø) 4 2 2
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/nve.go 46.67% (ø) 15 7 8
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/ospf.go 25.00% (ø) 16 4 12
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/pim.go 50.00% (ø) 12 6 6
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/prefix.go 75.00% (ø) 4 3 1
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/provider.go 0.06% (ø) 1611 1 1610
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/routemap.go 22.73% (ø) 22 5 17
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/snmp.go 81.82% (ø) 11 9 2
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/syslog.go 38.89% (ø) 18 7 11
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/system.go 3.23% (ø) 31 1 30
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/term.go 21.43% (ø) 14 3 11
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/user.go 40.00% (ø) 40 16 24
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/version.go 0.00% (ø) 7 0 7
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/vlan.go 16.67% (ø) 18 3 15
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/vpc.go 12.00% (ø) 25 3 22
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/vrf.go 100.00% (ø) 6 6 0
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/client.go 88.61% (+88.61%) 158 (+158) 140 (+140) 18 (+18) 🌟
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/doc.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/empty.go 100.00% (+100.00%) 10 (+10) 10 (+10) 0 🌟
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/list.go 100.00% (+100.00%) 24 (+24) 24 (+24) 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/provider/cisco/nxos/provider_test.go
  • github.com/ironcore-dev/network-operator/internal/transport/gnmiext/client_test.go
  • github.com/ironcore-dev/network-operator/internal/transport/gnmiext/empty_test.go
  • github.com/ironcore-dev/network-operator/internal/transport/gnmiext/list_test.go

@hardikdr hardikdr added the area/switch-automation Automation processes for network switch management and operations. label Apr 3, 2026
@hardikdr hardikdr added this to Roadmap Apr 3, 2026
When a gRPC call returns a status code that indicates a permanent failure
(e.g. InvalidArgument, NotFound, PermissionDenied, Unauthenticated),
retrying the request will not resolve the issue. Without marking these
errors as terminal, the controller-runtime reconciler keeps requeuing
the reconciliation indefinitely, wasting resources.

Introduce a TerminalErrorInterceptor that wraps errors with non-retryable
gRPC status codes as reconcile.TerminalError so the reconciler stops
retrying immediately.

Also fix error wrapping in GetDeviceByName which previously dropped the
underlying error, and add documentation to GetDeviceBySerial.
As we plan to use our `gnmiext` package also for other provider
implementations of other hardware vendors than Cisco, we now move it
outside of the cisco provider package scope.

With this change we are introducing a new `transport` package which will
house multiple packages related to transport/protocol specific utilities
and clients.
Extracts `NewClient`, `Option`, `WithDefaultTimeout`, the interceptors,
and the `auth` type from `internal/deviceutil` into a dedicated
`internal/transport/grpcext` package, mirroring the existing
`internal/transport/gnmiext` sibling. `deviceutil` now only contains
device CRD helpers and the `Connection` type.
The Configurable interface is used for both configuration and state
data, making the old name misleading. Rename it to DataElement, the
term used by the gNMI specification for any item addressable by a
path — regardless of whether it represents a leaf, container, or
entire subtree.

Update variable names in the nxos provider package to reflect the
intent of each call site: `updates` for Update, `deletes` for
Delete, `patches` for Patch, and `el` for generic slices, replacing
the ambiguous `conf` that implied configuration-only usage.
@felix-kaestner felix-kaestner marked this pull request as ready for review April 8, 2026 13:45
@felix-kaestner felix-kaestner requested a review from a team as a code owner April 8, 2026 13:45
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/internal/deviceutil 59.62% (+18.83%) 🎉
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr 48.10% (ø)
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos 10.21% (ø)
github.com/ironcore-dev/network-operator/internal/provider/openconfig 0.00% (ø)
github.com/ironcore-dev/network-operator/internal/transport/gnmiext 90.62% (+90.62%) 🌟
github.com/ironcore-dev/network-operator/internal/transport/grpcext 0.00% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/internal/deviceutil/deviceutil.go 59.62% (+18.83%) 52 (-24) 31 21 (-24) 🎉
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr/intf.go 46.15% (ø) 13 6 7
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr/provider.go 48.48% (ø) 66 32 34
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/acl.go 17.65% (ø) 17 3 14
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/banner.go 20.00% (ø) 10 2 8
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/bgp.go 20.75% (ø) 53 11 42
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/bgw.go 75.00% (ø) 4 3 1
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/cert.go 3.33% (ø) 30 1 29
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/dhcprelay.go 0.00% (ø) 3 0 3
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/dns.go 100.00% (ø) 4 4 0
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/evi.go 42.55% (ø) 47 20 27
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/feat.go 50.00% (ø) 2 1 1
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/grpc.go 13.33% (ø) 15 2 13
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/intf.go 18.44% (ø) 141 26 115
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/isis.go 44.44% (ø) 9 4 5
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/lldp.go 66.67% (ø) 3 2 1
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/ntp.go 50.00% (ø) 4 2 2
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/nve.go 46.67% (ø) 15 7 8
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/ospf.go 25.00% (ø) 16 4 12
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/pim.go 46.15% (ø) 13 6 7
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/prefix.go 75.00% (ø) 4 3 1
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/provider.go 0.06% (ø) 1631 1 1630
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/routemap.go 22.73% (ø) 22 5 17
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/snmp.go 81.82% (ø) 11 9 2
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/syslog.go 38.89% (ø) 18 7 11
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/system.go 3.23% (ø) 31 1 30
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/term.go 21.43% (ø) 14 3 11
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/user.go 40.00% (ø) 40 16 24
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/version.go 0.00% (ø) 7 0 7
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/vlan.go 16.67% (ø) 18 3 15
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/vpc.go 12.00% (ø) 25 3 22
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/vrf.go 100.00% (ø) 6 6 0
github.com/ironcore-dev/network-operator/internal/provider/openconfig/provider.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/client.go 88.61% (+88.61%) 158 (+158) 140 (+140) 18 (+18) 🌟
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/doc.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/empty.go 100.00% (+100.00%) 10 (+10) 10 (+10) 0 🌟
github.com/ironcore-dev/network-operator/internal/transport/gnmiext/list.go 100.00% (+100.00%) 24 (+24) 24 (+24) 0 🌟
github.com/ironcore-dev/network-operator/internal/transport/grpcext/grpcext.go 0.00% (ø) 29 (+29) 0 29 (+29)

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/provider/cisco/nxos/provider_test.go
  • github.com/ironcore-dev/network-operator/internal/transport/gnmiext/client_test.go
  • github.com/ironcore-dev/network-operator/internal/transport/gnmiext/empty_test.go
  • github.com/ironcore-dev/network-operator/internal/transport/gnmiext/list_test.go

var terminalCodes = []codes.Code{
codes.Unknown,
codes.InvalidArgument,
codes.NotFound,
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.

I'm not so sure about this one. It am thinking of a Get that fails with this error code -not sure if this is even the case- and for which the relevant data is later added by the action of a different controller. Selectively picking the doc it states: "[...]", such as gradual feature rollout [...]". So data may appear later and thus maybe this shouldn't be a TerminalError.

I acknowledge we don't have the necessary operational experience to make a sound decision at the moment. This seems however a nice concept we could use.

return nil
}
if string(b) != "[null]" {
if !nullRe.MatchString(string(b)) {
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.

We could think of only checking this only if we find an IOS-XR in client.capabilities.capabilities. That said, this is likely too much for now as we are unlikely to find this being used as valid value in different platform. On the other hand, as we increase the number of platforms supported we may have more of these particularities coming in. Anyhow, I would leave this at it is unless you think otherwise.

name string
conn grpc.ClientConnInterface
conf []Configurable
conf []DataElement
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.

may be we can rename conf to configs to be in line with the terminology above. If we want it generic then d, de, or data might be other options.

},
},
conf: []Configurable{new(Hostname)},
conf: []DataElement{new(Hostname)},
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.

If we are not generic then we could rename this to updates

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

Labels

area/switch-automation Automation processes for network switch management and operations.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants