[VOL-4931] openoltAdapter: memory leak seen in long term tests

This patch is a prerequisite for changes in the openoltAdapter to eliminate memory leaks and must be merged first.

Change-Id: I2e35407aac20047312fe3cf8b1c345396e6a4bd3
diff --git a/VERSION b/VERSION
index 534d9b5..6b0e58e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-7.3.3-dev
+7.4.1
\ No newline at end of file
diff --git a/pkg/ponresourcemanager/ponresourcemanager.go b/pkg/ponresourcemanager/ponresourcemanager.go
index d751723..807d4c8 100755
--- a/pkg/ponresourcemanager/ponresourcemanager.go
+++ b/pkg/ponresourcemanager/ponresourcemanager.go
@@ -192,6 +192,17 @@
 	return kvbackend
 }
 
+func (PONRMgr *PONResourceManager) CloseKVClient(ctx context.Context) {
+	if PONRMgr.KVStore != nil {
+		PONRMgr.KVStore.Client.Close(ctx)
+		PONRMgr.KVStore = nil
+	}
+	if PONRMgr.KVStoreForConfig != nil {
+		PONRMgr.KVStoreForConfig.Client.Close(ctx)
+		PONRMgr.KVStoreForConfig = nil
+	}
+}
+
 // NewPONResourceManager creates a new PON resource manager.
 func NewPONResourceManager(ctx context.Context, Technology string, DeviceType string, DeviceID string, Backend string, Address string, basePathKvStore string) (*PONResourceManager, error) {
 	var PONMgr PONResourceManager
diff --git a/pkg/techprofile/tech_profile.go b/pkg/techprofile/tech_profile.go
index 6d68f5a..dce43ed 100644
--- a/pkg/techprofile/tech_profile.go
+++ b/pkg/techprofile/tech_profile.go
@@ -178,6 +178,21 @@
 	*/
 }
 
+func (t *TechProfileMgr) CloseKVClient(ctx context.Context) {
+	if t.config.KVBackend != nil {
+		t.config.KVBackend.Client.Close(ctx)
+		t.config.KVBackend = nil
+	}
+	if t.config.DefaultTpKVBackend != nil {
+		t.config.DefaultTpKVBackend.Client.Close(ctx)
+		t.config.DefaultTpKVBackend = nil
+	}
+	if t.config.ResourceInstanceKVBacked != nil {
+		t.config.ResourceInstanceKVBacked.Client.Close(ctx)
+		t.config.ResourceInstanceKVBacked = nil
+	}
+}
+
 func NewTechProfile(ctx context.Context, resourceMgr iPonResourceMgr, kvStoreType string, kvStoreAddress string, basePathKvStore string) (*TechProfileMgr, error) {
 	var techprofileObj TechProfileMgr
 	logger.Debug(ctx, "initializing-techprofile-mananger")
diff --git a/pkg/techprofile/tech_profile_if.go b/pkg/techprofile/tech_profile_if.go
index 89a66b2..c936a56 100644
--- a/pkg/techprofile/tech_profile_if.go
+++ b/pkg/techprofile/tech_profile_if.go
@@ -25,6 +25,7 @@
 
 type TechProfileIf interface {
 	SetKVClient(ctx context.Context, pathPrefix string) *db.Backend
+	CloseKVClient(ctx context.Context)
 	GetTechProfileInstanceKey(ctx context.Context, tpID uint32, uniPortName string) string
 	GetTPInstance(ctx context.Context, path string) (interface{}, error)
 	CreateTechProfileInstance(ctx context.Context, tpID uint32, uniPortName string, intfID uint32) (interface{}, error)