@@ -25,10 +25,11 @@ import (
25
25
"sync"
26
26
"time"
27
27
28
- "github.com/apache/servicecomb-service-center/pkg/protect"
29
28
pb "github.com/go-chassis/cari/discovery"
30
29
"github.com/go-chassis/cari/pkg/errsvc"
31
30
31
+ "github.com/apache/servicecomb-service-center/pkg/protect"
32
+
32
33
"github.com/apache/servicecomb-service-center/datasource"
33
34
"github.com/apache/servicecomb-service-center/pkg/log"
34
35
"github.com/apache/servicecomb-service-center/pkg/util"
@@ -74,14 +75,18 @@ func RegisterInstance(ctx context.Context, in *pb.RegisterInstanceRequest) (*pb.
74
75
if popErr := populateInstanceDefaultValue (ctx , in .Instance ); popErr != nil {
75
76
return nil , popErr
76
77
}
78
+ var reRegistration bool
79
+ if len (in .Instance .InstanceId ) != 0 {
80
+ reRegistration = true
81
+ }
77
82
resp , err := datasource .GetMetadataManager ().RegisterInstance (ctx , in )
78
83
if err != nil {
79
84
log .Error (fmt .Sprintf ("register instance failed, endpoints %v, host '%s', serviceID %s, operator %s" ,
80
85
in .Instance .Endpoints , in .Instance .HostName , in .Instance .ServiceId , remoteIP ), err )
81
86
return nil , err
82
87
}
83
88
// re-register instance with id, should sync properties to peer
84
- if len ( in . Instance . InstanceId ) != 0 {
89
+ if reRegistration {
85
90
in .Instance .Properties [reRegisterTimestamp ] = time .Now ().String ()
86
91
err = PutInstanceProperties (ctx , & pb.UpdateInstancePropsRequest {
87
92
InstanceId : in .Instance .InstanceId ,
0 commit comments