From 15129ecd066abd666916a252c31cac91fdb33750 Mon Sep 17 00:00:00 2001 From: Aleksandr Balezin Date: Tue, 20 Jan 2026 13:51:47 +0300 Subject: [PATCH] fix: support CmdTimeout in netconf --- pkg/device/netconf/device.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/device/netconf/device.go b/pkg/device/netconf/device.go index 638f725..bc9ce54 100644 --- a/pkg/device/netconf/device.go +++ b/pkg/device/netconf/device.go @@ -221,7 +221,15 @@ func (m *NetconfDevice) Execute(command gcmd.Cmd) (gcmd.CmdRes, error) { var res []byte var err error ctx := context.Background() + if readTimeout := command.GetCmdTimeout(); readTimeout > 0 { + prevTimeout := m.connector.SetReadTimeout(readTimeout) + defer m.connector.SetReadTimeout(prevTimeout) + } + if cmdTimeout := command.GetCmdTimeout(); cmdTimeout > 0 { + if readTimeout := command.GetCmdTimeout(); readTimeout > cmdTimeout { + cmdTimeout = readTimeout + } newCtx, cancel := context.WithTimeout(ctx, cmdTimeout) ctx = newCtx defer cancel()