VOL-4427: Clear stale keys from etcd
Change-Id: I7a78b5bf6fceab6245e79b9372d0dfa91786328c
diff --git a/VERSION b/VERSION
index 3cf5751..fa8da20 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.5.7
+3.5.8
diff --git a/go.mod b/go.mod
index cf940c4..8a17831 100644
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4
- github.com/opencord/voltha-lib-go/v5 v5.0.6
+ github.com/opencord/voltha-lib-go/v5 v5.0.7
github.com/opencord/voltha-protos/v4 v4.2.0
go.etcd.io/etcd v0.0.0-20190930204107-236ac2a90522
google.golang.org/grpc v1.25.1
diff --git a/go.sum b/go.sum
index c8d8e5b..b971d22 100644
--- a/go.sum
+++ b/go.sum
@@ -141,8 +141,8 @@
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
-github.com/opencord/voltha-lib-go/v5 v5.0.6 h1:vJ6ZTNSjOiWAViCT5BfxEgv596d4KBov28a3rE5DDPI=
-github.com/opencord/voltha-lib-go/v5 v5.0.6/go.mod h1:i1fwPMicFccG38L200+IQAlfHSbszWg//jF1pDQxTPQ=
+github.com/opencord/voltha-lib-go/v5 v5.0.7 h1:ifz7QZp71OHdBLFvADGtd6eNjddn80dxiBKPhLXoY84=
+github.com/opencord/voltha-lib-go/v5 v5.0.7/go.mod h1:i1fwPMicFccG38L200+IQAlfHSbszWg//jF1pDQxTPQ=
github.com/opencord/voltha-protos/v4 v4.2.0 h1:QJZqHPRKa1E1xh40F3UA4xSjBI+6EmW7OfIcJqPNc4A=
github.com/opencord/voltha-protos/v4 v4.2.0/go.mod h1:wNzWqmTwe7+DbYbpmOX6eMlglREtMkNxIDv3lyI2bco=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
diff --git a/vendor/github.com/opencord/voltha-lib-go/v5/pkg/ponresourcemanager/ponresourcemanager.go b/vendor/github.com/opencord/voltha-lib-go/v5/pkg/ponresourcemanager/ponresourcemanager.go
index a8738ee..23bc6c7 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v5/pkg/ponresourcemanager/ponresourcemanager.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v5/pkg/ponresourcemanager/ponresourcemanager.go
@@ -1138,15 +1138,23 @@
var Value []byte
var err error
Path := fmt.Sprintf(ALLOC_ID_RESOURCE_MAP_PATH, PONRMgr.DeviceID, IntfONUID)
- Value, err = json.Marshal(AllocIDs)
- if err != nil {
- logger.Error(ctx, "failed to Marshal")
- return err
- }
+ if AllocIDs == nil {
+ // No more alloc ids associated with the key. Delete the key entirely
+ if err = PONRMgr.KVStore.Delete(ctx, Path); err != nil {
+ logger.Errorf(ctx, "Failed to delete key %s", Path)
+ return err
+ }
+ } else {
+ Value, err = json.Marshal(AllocIDs)
+ if err != nil {
+ logger.Error(ctx, "failed to Marshal")
+ return err
+ }
- if err = PONRMgr.KVStore.Put(ctx, Path, Value); err != nil {
- logger.Errorf(ctx, "Failed to update resource %s", Path)
- return err
+ if err = PONRMgr.KVStore.Put(ctx, Path, Value); err != nil {
+ logger.Errorf(ctx, "Failed to update resource %s", Path)
+ return err
+ }
}
return err
}
@@ -1162,15 +1170,23 @@
var err error
Path := fmt.Sprintf(GEMPORT_ID_RESOURCE_MAP_PATH, PONRMgr.DeviceID, IntfONUID)
logger.Debugf(ctx, "Updating gemport ids for %s", Path)
- Value, err = json.Marshal(GEMPortIDs)
- if err != nil {
- logger.Error(ctx, "failed to Marshal")
- return err
- }
+ if GEMPortIDs == nil {
+ // No more gemport ids associated with the key. Delete the key entirely
+ if err = PONRMgr.KVStore.Delete(ctx, Path); err != nil {
+ logger.Errorf(ctx, "Failed to delete key %s", Path)
+ return err
+ }
+ } else {
+ Value, err = json.Marshal(GEMPortIDs)
+ if err != nil {
+ logger.Error(ctx, "failed to Marshal")
+ return err
+ }
- if err = PONRMgr.KVStore.Put(ctx, Path, Value); err != nil {
- logger.Errorf(ctx, "Failed to update resource %s", Path)
- return err
+ if err = PONRMgr.KVStore.Put(ctx, Path, Value); err != nil {
+ logger.Errorf(ctx, "Failed to update resource %s", Path)
+ return err
+ }
}
return err
}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 22ca5b8..f406be3 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -58,7 +58,7 @@
# github.com/jcmturner/gofork v1.0.0
github.com/jcmturner/gofork/encoding/asn1
github.com/jcmturner/gofork/x/crypto/pbkdf2
-# github.com/opencord/voltha-lib-go/v5 v5.0.6
+# github.com/opencord/voltha-lib-go/v5 v5.0.7
## explicit
github.com/opencord/voltha-lib-go/v5/pkg/adapters
github.com/opencord/voltha-lib-go/v5/pkg/adapters/adapterif