Fix stale data on etcd after OLT device delete

Change-Id: I71681e1b3b245d79eee64df4aa32c877f05f08d8
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index ed7baf7..0e46594 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -23,6 +23,8 @@
 	"encoding/hex"
 	"errors"
 	"fmt"
+	"github.com/opencord/voltha-lib-go/v7/pkg/db"
+	"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
 	"io"
 	"net"
 	"strconv"
@@ -2068,6 +2070,19 @@
 		_ = dh.resourceMgr[dh.totalPonPorts].DeleteAllFlowIDsForGemForIntf(ctx)
 	}
 
+	// Take one final sweep at cleaning up KV store for the OLT device
+	// Clean everything at <base-path-prefix>/openolt/<device-id>
+	kvClient, err := kvstore.NewEtcdClient(ctx, dh.openOLT.KVStoreAddress, rsrcMgr.KvstoreTimeout, log.FatalLevel)
+	if err == nil {
+		kvBackend := &db.Backend{
+			Client:     kvClient,
+			StoreType:  dh.openOLT.KVStoreType,
+			Address:    dh.openOLT.KVStoreAddress,
+			Timeout:    rsrcMgr.KvstoreTimeout,
+			PathPrefix: fmt.Sprintf(rsrcMgr.BasePathKvStore, dh.cm.Backend.PathPrefix, dh.device.Id)}
+		_ = kvBackend.DeleteWithPrefix(ctx, "")
+	}
+
 	/*Delete ONU map for the device*/
 	dh.onus.Range(func(key interface{}, value interface{}) bool {
 		dh.onus.Delete(key)