Skip to content

Implement NX-OS reprovisioning via NX-API - #381

Merged
felix-kaestner merged 6 commits into
mainfrom
chore/nxos-reprovision
Jul 23, 2026
Merged

Implement NX-OS reprovisioning via NX-API#381
felix-kaestner merged 6 commits into
mainfrom
chore/nxos-reprovision

Conversation

@felix-kaestner

Copy link
Copy Markdown
Contributor

Replace the defunct GNMI-based reprovisioning with NXAPI JSON-RPC calls. The new implementation issues two requests:

  1. boot poap enable + copy running-config startup-config (batched with stop-on-error rollback)
  2. reload (separate request that tolerates transport errors because the device goes down before responding)

Add nxapi.IsTransportError to distinguish network-level errors (EOF, timeout, connection reset) from logical errors (RPCError, HTTPError), enabling callers of disruptive commands to tolerate expected connection drops.

Remove the now unused BootPOAP GNMI type.

@felix-kaestner
felix-kaestner requested a review from a team May 27, 2026 16:52
@felix-kaestner
felix-kaestner force-pushed the chore/nxos-reprovision branch from 9ac1150 to 48f2d50 Compare May 28, 2026 08:30
@felix-kaestner
felix-kaestner marked this pull request as draft June 4, 2026 09:23
@felix-kaestner
felix-kaestner force-pushed the chore/nxos-reprovision branch from 48f2d50 to 72080cf Compare June 19, 2026 12:14
@felix-kaestner
felix-kaestner marked this pull request as ready for review June 19, 2026 12:15
@felix-kaestner
felix-kaestner force-pushed the chore/nxos-reprovision branch from 72080cf to 8547f3b Compare June 23, 2026 12:24
@felix-kaestner
felix-kaestner force-pushed the chore/nxos-reprovision branch from 8547f3b to 28958c3 Compare July 8, 2026 16:30
Comment thread internal/provider/cisco/nxos/provider.go Outdated
Comment thread internal/transport/nxapi/nxapi.go Outdated
@felix-kaestner
felix-kaestner force-pushed the chore/nxos-reprovision branch 2 times, most recently from 346057f to 533f156 Compare July 17, 2026 14:52
Replace the defunct GNMI-based reprovisioning with NXAPI
JSON-RPC calls. The new implementation issues two requests:

1. boot poap enable + copy running-config startup-config
   (batched with stop-on-error rollback)
2. reload (separate request that tolerates transport errors
   because the device goes down before responding)

Add nxapi.IsTransportError to distinguish network-level
errors (EOF, timeout, connection reset) from logical errors
(RPCError, HTTPError), enabling callers of disruptive
commands to tolerate expected connection drops.

Remove the now unused BootPOAP GNMI type.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Move the maintenance annotation deletion to after the switch
statement so it is only removed when the action succeeds. This
allows the reconciler to retry failed maintenance operations on
the next reconciliation instead of requiring the user to
re-apply the annotation.

Additionally, return a terminal error for unknown maintenance
actions since retrying will never succeed.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Add a functional option to nxapi.NewClient that overrides
the port in the connection address. This allows tests to
point the client at an httptest server on a random port.

Reprovision now reuses p.nxapi if already set (e.g. from
Connect or injected by a test), falling back to creating
a standalone client with port stripping for production.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Replace the positional timeout parameter in NewClient with a
WithTimeout option, consistent with WithPort. The default is
0 (no timeout).

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Maintenance operations (reboot, factory reset, reprovision)
require an established provider connection. Previously they
were called without Connect, which meant Reboot and
FactoryReset would use a nil gRPC connection and Reprovision
had to create its own NX-API client as a workaround.

Wrap device-targeting maintenance actions in the same
Connect/Disconnect pattern used by reconcile and
reconcileMinimal.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
Now that reconcileMaintenance calls Connect before invoking
Reprovision, the fallback client creation is unnecessary.
Reprovision can use p.nxapi directly, matching all other
provider methods.

Signed-off-by: Felix Kästner <felix.kaestner@sap.com>
@felix-kaestner
felix-kaestner force-pushed the chore/nxos-reprovision branch from 533f156 to decbea9 Compare July 22, 2026 13:42
@github-actions github-actions Bot added size/XL and removed size/L labels Jul 22, 2026
@github-actions

Copy link
Copy Markdown

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

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/hack/nxapi 0.00% (ø)
github.com/ironcore-dev/network-operator/internal/controller/core 61.84% (-0.18%) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos 9.51% (+0.26%) 👍
github.com/ironcore-dev/network-operator/internal/transport/nxapi 86.67% (+17.75%) 🎉

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/hack/nxapi/main.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/internal/controller/core/device_controller.go 64.91% (-1.25%) 265 (+5) 172 93 (+5) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/provider.go 0.39% (+0.34%) 2031 (-3) 8 (+7) 2023 (-10) 👍
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/system.go 3.33% (+0.11%) 30 (-1) 1 29 (-1) 👍
github.com/ironcore-dev/network-operator/internal/transport/nxapi/nxapi.go 86.67% (+17.75%) 90 (+16) 78 (+27) 12 (-11) 🎉

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/nxos/reprovision_test.go
  • github.com/ironcore-dev/network-operator/internal/transport/nxapi/nxapi_test.go

@felix-kaestner
felix-kaestner merged commit d565c51 into main Jul 23, 2026
24 checks passed
@felix-kaestner
felix-kaestner deleted the chore/nxos-reprovision branch July 23, 2026 14:51
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.

2 participants