Skip to content

Commit 04b8429

Browse files
authored
fix the bug that registering without instanceid will add reregistration property (#1502)
1 parent 9083ad2 commit 04b8429

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

server/service/disco/instance.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ import (
2525
"sync"
2626
"time"
2727

28-
"github.com/apache/servicecomb-service-center/pkg/protect"
2928
pb "github.com/go-chassis/cari/discovery"
3029
"github.com/go-chassis/cari/pkg/errsvc"
3130

31+
"github.com/apache/servicecomb-service-center/pkg/protect"
32+
3233
"github.com/apache/servicecomb-service-center/datasource"
3334
"github.com/apache/servicecomb-service-center/pkg/log"
3435
"github.com/apache/servicecomb-service-center/pkg/util"
@@ -74,14 +75,18 @@ func RegisterInstance(ctx context.Context, in *pb.RegisterInstanceRequest) (*pb.
7475
if popErr := populateInstanceDefaultValue(ctx, in.Instance); popErr != nil {
7576
return nil, popErr
7677
}
78+
var reRegistration bool
79+
if len(in.Instance.InstanceId) != 0 {
80+
reRegistration = true
81+
}
7782
resp, err := datasource.GetMetadataManager().RegisterInstance(ctx, in)
7883
if err != nil {
7984
log.Error(fmt.Sprintf("register instance failed, endpoints %v, host '%s', serviceID %s, operator %s",
8085
in.Instance.Endpoints, in.Instance.HostName, in.Instance.ServiceId, remoteIP), err)
8186
return nil, err
8287
}
8388
// re-register instance with id, should sync properties to peer
84-
if len(in.Instance.InstanceId) != 0 {
89+
if reRegistration {
8590
in.Instance.Properties[reRegisterTimestamp] = time.Now().String()
8691
err = PutInstanceProperties(ctx, &pb.UpdateInstancePropsRequest{
8792
InstanceId: in.Instance.InstanceId,

0 commit comments

Comments
 (0)