[VOL-5542]: Free resources only if the deleteonu is successful
Change-Id: I2b837f0e32b404fcd81999b8bf817da42fde6bf6
Signed-off-by: balaji.nagarajan <balaji.nagarajan@radisys.com>
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index fbaf659..e08a7b9 100755
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -3493,9 +3493,6 @@
}
logger.Debugw(ctx, "removed-onu-gem-info", log.Fields{"intf": intfID, "onu-device": onu, "onugem": onuGem})
}
- dh.resourceMgr[intfID].FreeonuID(ctx, []uint32{onuID})
- dh.onus.Delete(onuKey)
- dh.discOnus.Delete(onuSn)
subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), dh.cfg.RPCTimeout)
// Now clear the ONU on the OLT
@@ -3506,6 +3503,11 @@
"onu-id": onuID}, err).Log()
}
cancel()
+
+ //free resources only if the deleteonu is successful
+ dh.resourceMgr[intfID].FreeonuID(ctx, []uint32{onuID})
+ dh.onus.Delete(onuKey)
+ dh.discOnus.Delete(onuSn)
return nil
}
func (dh *DeviceHandler) removeFlowFromDevice(ctx context.Context, flowID uint64, intfID uint32) {