[VOL-5422]Update the voltha-lib-go and voltha-protos versions to the latest for VOLTHA Components
Change-Id: I9eac4a4a6de4b441f5f03a1d589b19757f3b8433
Signed-off-by: pnalmas <praneeth.nalmas@radisys.com>
diff --git a/VERSION b/VERSION
index 2bf1c1c..f90b1af 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.3.1
+2.3.2
diff --git a/go.mod b/go.mod
index 93da627..d3dfeb5 100644
--- a/go.mod
+++ b/go.mod
@@ -12,7 +12,7 @@
github.com/golang/protobuf v1.5.2
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/opencord/goloxi v1.0.1
- github.com/opencord/voltha-lib-go/v7 v7.6.3
+ github.com/opencord/voltha-lib-go/v7 v7.6.5
github.com/opencord/voltha-protos/v5 v5.6.2
github.com/stretchr/testify v1.7.0
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
diff --git a/go.sum b/go.sum
index 5bd9c49..bde27b4 100644
--- a/go.sum
+++ b/go.sum
@@ -178,8 +178,8 @@
github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
github.com/opencord/goloxi v1.0.1 h1:QCOZUqgNLi72ylaIPWSLvSvGVDB2FHyatIkAePXr+Dk=
github.com/opencord/goloxi v1.0.1/go.mod h1:A5U6uO6EaPuQkB5N1RjIV66tYgsKejiGTsEZrU/c19A=
-github.com/opencord/voltha-lib-go/v7 v7.6.3 h1:r/1kD878aJD6nvKv3VLZQ1zqr0mM+dL/yZ/qupVeETU=
-github.com/opencord/voltha-lib-go/v7 v7.6.3/go.mod h1:uGmArLg+nSZd49YXv7ZaD48FA5c+siEFxnyRuldwv6Y=
+github.com/opencord/voltha-lib-go/v7 v7.6.5 h1:5WYdjjIQX387Xhy2DPXtF2kuImQ0QTInllVWfRidqTo=
+github.com/opencord/voltha-lib-go/v7 v7.6.5/go.mod h1:uGmArLg+nSZd49YXv7ZaD48FA5c+siEFxnyRuldwv6Y=
github.com/opencord/voltha-protos/v5 v5.6.2 h1:evT3MYShV8uzLQAfF+qXS6nbdKRNewxifDK49XzqtVM=
github.com/opencord/voltha-protos/v5 v5.6.2/go.mod h1:E/Jn3DNu8VGRBCgIWSSg4sWtTBiNuQGSFvHyNH1XlyM=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/backend.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/backend.go
index dc24fe6..bb99970 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/backend.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/backend.go
@@ -87,6 +87,7 @@
func (b *Backend) makePath(ctx context.Context, key string) string {
path := fmt.Sprintf("%s/%s", b.PathPrefix, key)
+ logger.Debugw(ctx, "make-path", log.Fields{"key": key, "path": path})
return path
}
@@ -145,7 +146,7 @@
}
// Extract Alive status of Kvstore based on type of error
-func (b *Backend) isErrorIndicatingAliveKvstore(ctx context.Context, err error) bool {
+func (b *Backend) isErrorIndicatingAliveKvstore(err error) bool {
// Alive unless observed an error indicating so
alive := true
@@ -188,7 +189,7 @@
pair, err := b.Client.List(ctx, formattedPath)
- b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(ctx, err))
+ b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(err))
return pair, err
}
@@ -203,7 +204,37 @@
pair, err := b.Client.Get(ctx, formattedPath)
- b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(ctx, err))
+ b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(err))
+
+ return pair, err
+}
+
+// GetWithPrefix retrieves one or more items that match the specified key prefix
+func (b *Backend) GetWithPrefix(ctx context.Context, prefixKey string) (map[string]*kvstore.KVPair, error) {
+ span, ctx := log.CreateChildSpan(ctx, "kvs-get-with-prefix")
+ defer span.Finish()
+
+ formattedPath := b.makePath(ctx, prefixKey)
+ logger.Debugw(ctx, "get-entries-matching-prefix-key", log.Fields{"key": prefixKey, "path": formattedPath})
+
+ pair, err := b.Client.GetWithPrefix(ctx, formattedPath)
+
+ b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(err))
+
+ return pair, err
+}
+
+// GetWithPrefixKeysOnly retrieves one or more keys that match the specified key prefix
+func (b *Backend) GetWithPrefixKeysOnly(ctx context.Context, prefixKey string) ([]string, error) {
+ span, ctx := log.CreateChildSpan(ctx, "kvs-get-with-prefix")
+ defer span.Finish()
+
+ formattedPath := b.makePath(ctx, prefixKey)
+ logger.Debugw(ctx, "get-keys-entries-matching-prefix-key", log.Fields{"key": prefixKey, "path": formattedPath})
+
+ pair, err := b.Client.GetWithPrefixKeysOnly(ctx, formattedPath)
+
+ b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(err))
return pair, err
}
@@ -218,7 +249,7 @@
err := b.Client.Put(ctx, formattedPath, value)
- b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(ctx, err))
+ b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(err))
return err
}
@@ -233,7 +264,7 @@
err := b.Client.Delete(ctx, formattedPath)
- b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(ctx, err))
+ b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(err))
return err
}
@@ -247,7 +278,7 @@
err := b.Client.DeleteWithPrefix(ctx, formattedPath)
- b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(ctx, err))
+ b.updateLiveness(ctx, b.isErrorIndicatingAliveKvstore(err))
return err
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/client.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/client.go
index c59f4b3..85bc5f5 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/client.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/client.go
@@ -76,6 +76,8 @@
type Client interface {
List(ctx context.Context, key string) (map[string]*KVPair, error)
Get(ctx context.Context, key string) (*KVPair, error)
+ GetWithPrefix(ctx context.Context, prefixKey string) (map[string]*KVPair, error)
+ GetWithPrefixKeysOnly(ctx context.Context, prefixKey string) ([]string, error)
Put(ctx context.Context, key string, value interface{}) error
Delete(ctx context.Context, key string) error
DeleteWithPrefix(ctx context.Context, prefixKey string) error
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdclient.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdclient.go
index 8439afe..c5df1d8 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdclient.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/etcdclient.go
@@ -171,6 +171,57 @@
}
}
+// GetWithPrefix fetches all key-value pairs with the specified prefix from etcd.
+// Returns a map of key-value pairs or an error if the operation fails.
+func (c *EtcdClient) GetWithPrefix(ctx context.Context, prefixKey string) (map[string]*KVPair, error) {
+ // Acquire a client from the pool
+ client, err := c.pool.Get(ctx)
+ if err != nil {
+ return nil, fmt.Errorf("failed to get client from pool: %w", err)
+ }
+ defer c.pool.Put(client)
+
+ // Fetch keys with the prefix
+ resp, err := client.Get(ctx, prefixKey, v3Client.WithPrefix())
+ if err != nil {
+ return nil, fmt.Errorf("failed to fetch entries for prefix %s: %w", prefixKey, err)
+ }
+
+ // Initialize the result map
+ result := make(map[string]*KVPair)
+
+ // Iterate through the fetched key-value pairs and populate the map
+ for _, ev := range resp.Kvs {
+ result[string(ev.Key)] = NewKVPair(string(ev.Key), ev.Value, "", ev.Lease, ev.Version)
+ }
+
+ return result, nil
+}
+
+// GetWithPrefixKeysOnly retrieves only the keys that match a given prefix.
+func (c *EtcdClient) GetWithPrefixKeysOnly(ctx context.Context, prefixKey string) ([]string, error) {
+ // Acquire a client from the pool
+ client, err := c.pool.Get(ctx)
+ if err != nil {
+ return nil, fmt.Errorf("failed to get client from pool: %w", err)
+ }
+ defer c.pool.Put(client)
+
+ // Fetch keys with the prefix
+ resp, err := client.Get(ctx, prefixKey, v3Client.WithPrefix(), v3Client.WithKeysOnly())
+ if err != nil {
+ return nil, fmt.Errorf("failed to fetch entries for prefix %s: %w", prefixKey, err)
+ }
+
+ // Extract keys from the response
+ keys := []string{}
+ for _, kv := range resp.Kvs {
+ keys = append(keys, string(kv.Key))
+ }
+
+ return keys, nil
+}
+
// Put writes a key-value pair to the KV store. Value can only be a string or []byte since the etcd API
// accepts only a string as a value for a put operation. Timeout defines how long the function will
// wait for a response
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/redisclient.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/redisclient.go
index 742916c..7ed4159 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/redisclient.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore/redisclient.go
@@ -415,3 +415,41 @@
logger.Errorw(ctx, "error-closing-client", log.Fields{"error": err})
}
}
+
+func (c *RedisClient) GetWithPrefix(ctx context.Context, prefix string) (map[string]*KVPair, error) {
+ var err error
+ var keys []string
+ m := make(map[string]*KVPair)
+ var values []interface{}
+
+ if keys, err = c.scanAllKeysWithPrefix(ctx, prefix); err != nil {
+ return nil, err
+ }
+
+ if len(keys) != 0 {
+ values, err = c.redisAPI.MGet(ctx, keys...).Result()
+ if err != nil {
+ return nil, err
+ }
+ }
+ for i, key := range keys {
+ if valBytes, err := ToByte(values[i]); err == nil {
+ m[key] = NewKVPair(key, interface{}(valBytes), "", 0, 0)
+ }
+ }
+ return m, nil
+}
+
+func (c *RedisClient) GetWithPrefixKeysOnly(ctx context.Context, prefix string) ([]string, error) {
+ // Use the scanAllKeysWithPrefix function to fetch keys matching the prefix
+ keys, err := c.scanAllKeysWithPrefix(ctx, prefix)
+ if err != nil {
+ return nil, fmt.Errorf("failed to scan keys with prefix %s: %v", prefix, err)
+ }
+
+ if len(keys) == 0 {
+ logger.Debugw(ctx, "no-keys-found", log.Fields{"prefix": prefix})
+ }
+
+ return keys, nil
+}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 5a8cf53..15cab78 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -58,7 +58,7 @@
## explicit
github.com/opencord/goloxi
github.com/opencord/goloxi/of13
-# github.com/opencord/voltha-lib-go/v7 v7.6.3
+# github.com/opencord/voltha-lib-go/v7 v7.6.5
## explicit
github.com/opencord/voltha-lib-go/v7/pkg/config
github.com/opencord/voltha-lib-go/v7/pkg/db