This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 611a3b1 SCB-2176 Fix: remove all instances properties (#909)
611a3b1 is described below
commit 611a3b1557a133ae5b5eacd0e668f474b2295145
Author: little-cui <[email protected]>
AuthorDate: Mon Mar 22 16:01:07 2021 +0800
SCB-2176 Fix: remove all instances properties (#909)
---
datasource/etcd/util.go | 2 +-
datasource/etcd/util/instance_util.go | 6 ++++--
datasource/etcd/util/instance_util_test.go | 4 ++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/datasource/etcd/util.go b/datasource/etcd/util.go
index 497b69a..1564c18 100644
--- a/datasource/etcd/util.go
+++ b/datasource/etcd/util.go
@@ -299,7 +299,7 @@ func getServiceDetailUtil(ctx context.Context,
serviceDetailOpt ServiceDetailOpt
Count: instanceCount}
continue
}
- instances, err :=
serviceUtil.GetAllInstancesOfOneService(ctx, domainProject, serviceID)
+ instances, err :=
serviceUtil.GetInstancesWithoutProperties(ctx, domainProject, serviceID)
if err != nil {
log.Errorf(err, "get service[%s]'s all
instances failed", serviceID)
return nil, err
diff --git a/datasource/etcd/util/instance_util.go
b/datasource/etcd/util/instance_util.go
index 9a53e48..20b72df 100644
--- a/datasource/etcd/util/instance_util.go
+++ b/datasource/etcd/util/instance_util.go
@@ -72,7 +72,7 @@ func FormatRevision(revs, counts []int64) (s string) {
return fmt.Sprintf("%x", sha1.Sum(util.StringToBytesWithNoCopy(s)))
}
-func GetAllInstancesOfOneService(ctx context.Context, domainProject string,
serviceID string) ([]*pb.MicroServiceInstance, error) {
+func GetInstancesWithoutProperties(ctx context.Context, domainProject string,
serviceID string) ([]*pb.MicroServiceInstance, error) {
key := path.GenerateInstanceKey(domainProject, serviceID, "")
opts := append(FromContext(ctx), client.WithStrKey(key),
client.WithPrefix())
resp, err := kv.Store().Instance().Search(ctx, opts...)
@@ -83,7 +83,9 @@ func GetAllInstancesOfOneService(ctx context.Context,
domainProject string, serv
instances := make([]*pb.MicroServiceInstance, 0, len(resp.Kvs))
for _, kv := range resp.Kvs {
- instances = append(instances,
kv.Value.(*pb.MicroServiceInstance))
+ instance := kv.Value.(*pb.MicroServiceInstance)
+ instance.Properties = nil
+ instances = append(instances, instance)
}
return instances, nil
}
diff --git a/datasource/etcd/util/instance_util_test.go
b/datasource/etcd/util/instance_util_test.go
index e062d15..53d7127 100644
--- a/datasource/etcd/util/instance_util_test.go
+++ b/datasource/etcd/util/instance_util_test.go
@@ -54,9 +54,9 @@ func TestGetInstance(t *testing.T) {
t.Fatalf(`GetInstance failed`)
}
- _, err = GetAllInstancesOfOneService(context.Background(), "", "")
+ _, err = GetInstancesWithoutProperties(context.Background(), "", "")
if err != nil {
- t.Fatalf(`GetAllInstancesOfOneService failed`)
+ t.Fatalf(`GetInstancesWithoutProperties failed`)
}
_, err = QueryServiceInstancesKvs(context.Background(), "", 0)