VOL-2101 readiness and liveliness check added to message-bus and etcd
updated vendor folder
Change-Id: I0c1b983bf47e2740e0a24ea0c3a05a803caff15c
updated testcases
diff --git a/vendor/github.com/opencord/voltha-lib-go/v2/pkg/db/kvstore/etcdclient.go b/vendor/github.com/opencord/voltha-lib-go/v2/pkg/db/kvstore/etcdclient.go
index e8bc92c..3ae767c 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v2/pkg/db/kvstore/etcdclient.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v2/pkg/db/kvstore/etcdclient.go
@@ -38,6 +38,9 @@
lockToMutexLock sync.Mutex
}
+// Connection Timeout in Seconds
+var connTimeout int = 2
+
// NewEtcdClient returns a new client for the Etcd KV store
func NewEtcdClient(addr string, timeout int) (*EtcdClient, error) {
duration := GetDuration(timeout)
@@ -188,8 +191,13 @@
return nil, fmt.Errorf("unexpected-type%T", value)
}
+ duration := GetDuration(connTimeout)
+
// Create a lease
- resp, err := c.ectdAPI.Grant(context.Background(), ttl)
+ ctx, cancel := context.WithTimeout(context.Background(), duration)
+ defer cancel()
+
+ resp, err := c.ectdAPI.Grant(ctx, ttl)
if err != nil {
log.Error(err)
return nil, err
@@ -255,8 +263,12 @@
func (c *EtcdClient) ReleaseAllReservations() error {
c.writeLock.Lock()
defer c.writeLock.Unlock()
+ duration := GetDuration(connTimeout)
+ ctx, cancel := context.WithTimeout(context.Background(), duration)
+ defer cancel()
+
for key, leaseID := range c.keyReservations {
- _, err := c.ectdAPI.Revoke(context.Background(), *leaseID)
+ _, err := c.ectdAPI.Revoke(ctx, *leaseID)
if err != nil {
log.Errorw("cannot-release-reservation", log.Fields{"key": key, "error": err})
return err
@@ -277,8 +289,12 @@
if leaseID, ok = c.keyReservations[key]; !ok {
return nil
}
+ duration := GetDuration(connTimeout)
+ ctx, cancel := context.WithTimeout(context.Background(), duration)
+ defer cancel()
+
if leaseID != nil {
- _, err := c.ectdAPI.Revoke(context.Background(), *leaseID)
+ _, err := c.ectdAPI.Revoke(ctx, *leaseID)
if err != nil {
log.Error(err)
return err
@@ -299,9 +315,12 @@
if leaseID, ok = c.keyReservations[key]; !ok {
return errors.New("key-not-reserved")
}
+ duration := GetDuration(connTimeout)
+ ctx, cancel := context.WithTimeout(context.Background(), duration)
+ defer cancel()
if leaseID != nil {
- _, err := c.ectdAPI.KeepAliveOnce(context.Background(), *leaseID)
+ _, err := c.ectdAPI.KeepAliveOnce(ctx, *leaseID)
if err != nil {
log.Errorw("lease-may-have-expired", log.Fields{"error": err})
return err