Skip to content

Commit 1fc7a1a

Browse files
committed
[VOL-5585] Reset device transient state on context expiry in stopManagingDevice
Signed-off-by: bseeniva <balaji.seenivasan@radisys.com>
1 parent 277c269 commit 1fc7a1a

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7.21
1+
3.7.22

rw_core/core/device/manager.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ func (dMgr *Manager) stopManagingDevice(ctx context.Context, id string) {
200200
}
201201
if agent := dMgr.getDeviceAgent(ctx, id); agent != nil {
202202
if err := agent.stop(ctx); err != nil {
203+
// If the context expired before stop could process, reset the transient state to NONE
204+
// so that subsequent requests for this device can proceed
205+
if ctx.Err() != nil {
206+
newCtx, cancel := context.WithTimeout(context.Background(), dMgr.rpcTimeout)
207+
if err1 := agent.updateTransientState(newCtx, core.DeviceTransientState_NONE); err1 != nil {
208+
logger.Errorw(ctx, "failed-to-reset-transient-state-to-none", log.Fields{"device-id": agent.deviceID, "error": err1})
209+
}
210+
cancel()
211+
}
203212
logger.Warnw(ctx, "unable-to-stop-device-agent", log.Fields{"device-id": agent.deviceID, "error": err})
204213
}
205214
dMgr.deleteDeviceAgentFromMap(agent)

0 commit comments

Comments
 (0)