[VOL-5372] OpenONU Adapter hits an exception while trying to configure techprofile during device delete in progress

Change-Id: I4db1cbaf2d88d30dcdafb7c85bb41dca36732926
Signed-off-by: Praneeth Nalmas <praneeth.nalmas@radisys.com>
diff --git a/internal/pkg/core/openonu.go b/internal/pkg/core/openonu.go
index f1b5581..4e8374d 100755
--- a/internal/pkg/core/openonu.go
+++ b/internal/pkg/core/openonu.go
@@ -949,6 +949,14 @@
 	logger.Info(ctx, "download-tech-profile", log.Fields{"device-id": tProfile.DeviceId, "uni-id": tProfile.UniId})
 
 	if handler := oo.getDeviceHandler(ctx, tProfile.DeviceId, false); handler != nil {
+		handler.RLockMutexDeletionInProgressFlag()
+		if handler.GetDeletionInProgress() {
+			logger.Warnw(ctx, "Device deletion  in progress - avoid processing Tech Profile", log.Fields{"device-id": tProfile.DeviceId})
+
+			handler.RUnlockMutexDeletionInProgressFlag()
+			return nil, fmt.Errorf(fmt.Sprintf("Can't proceed, device  deletion is in progress-%s", tProfile.DeviceId))
+		}
+		handler.RUnlockMutexDeletionInProgressFlag()
 		if err := handler.handleTechProfileDownloadRequest(log.WithSpanFromContext(context.Background(), ctx), tProfile); err != nil {
 			return nil, err
 		}