[VOL-3910] Hanging pm data resources in etcd after reconcile

Change-Id: I035c039e4f685177146ba16bb603844619938470
diff --git a/VERSION b/VERSION
index 4f415ee..9579863 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.2.7-dev179
+1.2.7-dev181
diff --git a/internal/pkg/onuadaptercore/onu_metrics_manager.go b/internal/pkg/onuadaptercore/onu_metrics_manager.go
index 41efe82..d94e102 100644
--- a/internal/pkg/onuadaptercore/onu_metrics_manager.go
+++ b/internal/pkg/onuadaptercore/onu_metrics_manager.go
@@ -21,6 +21,10 @@
 	"context"
 	"encoding/json"
 	"fmt"
+	"math"
+	"sync"
+	"time"
+
 	"github.com/looplab/fsm"
 	"github.com/opencord/omci-lib-go"
 	me "github.com/opencord/omci-lib-go/generated"
@@ -28,9 +32,6 @@
 	"github.com/opencord/voltha-lib-go/v4/pkg/db/kvstore"
 	"github.com/opencord/voltha-lib-go/v4/pkg/log"
 	"github.com/opencord/voltha-protos/v4/go/voltha"
-	"math"
-	"sync"
-	"time"
 )
 
 const (
@@ -2572,13 +2573,20 @@
 		logger.Errorw(ctx, "pmKvStore not set - abort", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
 		return fmt.Errorf(fmt.Sprintf("pmKvStore-not-set-abort-%s", mm.pDeviceHandler.deviceID))
 	}
-
-	if err := mm.pmKvStore.Delete(ctx, ""); err != nil {
-		logger.Errorw(ctx, "unable to delete PM data from kv store", log.Fields{"deviceID": mm.pDeviceHandler.deviceID, "err": err})
-		return err
+	var value error
+	for n := range mm.groupMetricMap {
+		if err := mm.pmKvStore.Delete(ctx, n); err != nil {
+			logger.Errorw(ctx, "clearPmGroupData - fail", log.Fields{"deviceID": mm.pDeviceHandler.deviceID, "groupName": n, "err": err})
+			value = err
+			// do not abort this procedure - continue to delete next group.
+		} else {
+			logger.Debugw(ctx, "clearPmGroupData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID, "groupName": n})
+		}
 	}
-	logger.Debugw(ctx, "clearAllPmData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
-	return nil
+	if value == nil {
+		logger.Debugw(ctx, "clearAllPmData - success", log.Fields{"device-id": mm.pDeviceHandler.deviceID})
+	}
+	return value
 }
 
 func (mm *onuMetricsManager) appendIfMissingString(slice []string, n string) []string {