This is an automated email from the ASF dual-hosted git repository.

humingcheng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git


The following commit(s) were added to refs/heads/dev by this push:
     new 04b84295 fix the bug that registering without instanceid will add 
reregistration property (#1502)
04b84295 is described below

commit 04b842958702f176b12245374649a48405c1948f
Author: Wanghb1 <[email protected]>
AuthorDate: Thu Mar 6 19:41:05 2025 +0800

    fix the bug that registering without instanceid will add reregistration 
property (#1502)
---
 server/service/disco/instance.go | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/server/service/disco/instance.go b/server/service/disco/instance.go
index 992ff8b6..27ff878d 100644
--- a/server/service/disco/instance.go
+++ b/server/service/disco/instance.go
@@ -25,10 +25,11 @@ import (
        "sync"
        "time"
 
-       "github.com/apache/servicecomb-service-center/pkg/protect"
        pb "github.com/go-chassis/cari/discovery"
        "github.com/go-chassis/cari/pkg/errsvc"
 
+       "github.com/apache/servicecomb-service-center/pkg/protect"
+
        "github.com/apache/servicecomb-service-center/datasource"
        "github.com/apache/servicecomb-service-center/pkg/log"
        "github.com/apache/servicecomb-service-center/pkg/util"
@@ -74,6 +75,10 @@ func RegisterInstance(ctx context.Context, in 
*pb.RegisterInstanceRequest) (*pb.
        if popErr := populateInstanceDefaultValue(ctx, in.Instance); popErr != 
nil {
                return nil, popErr
        }
+       var reRegistration bool
+       if len(in.Instance.InstanceId) != 0 {
+               reRegistration = true
+       }
        resp, err := datasource.GetMetadataManager().RegisterInstance(ctx, in)
        if err != nil {
                log.Error(fmt.Sprintf("register instance failed, endpoints %v, 
host '%s', serviceID %s, operator %s",
@@ -81,7 +86,7 @@ func RegisterInstance(ctx context.Context, in 
*pb.RegisterInstanceRequest) (*pb.
                return nil, err
        }
        // re-register instance with id, should sync properties to peer
-       if len(in.Instance.InstanceId) != 0 {
+       if reRegistration {
                in.Instance.Properties[reRegisterTimestamp] = 
time.Now().String()
                err = PutInstanceProperties(ctx, &pb.UpdateInstancePropsRequest{
                        InstanceId: in.Instance.InstanceId,

Reply via email to