diff --git a/apiserver/eurekaserver/server.go b/apiserver/eurekaserver/server.go index b30433522..27c0fac7f 100644 --- a/apiserver/eurekaserver/server.go +++ b/apiserver/eurekaserver/server.go @@ -305,7 +305,7 @@ func (h *EurekaServer) Run(errCh chan error) { } else { err = server.ServeTLS(ln, h.tlsInfo.CertFile, h.tlsInfo.KeyFile) } - if err != nil { + if err != nil && err != http.ErrServerClosed { log.Errorf("%+v", err) if !h.restart { log.Infof("not in restart progress, broadcast error") diff --git a/bootstrap/server.go b/bootstrap/server.go index 3fbbb0a3a..ea2d1f674 100644 --- a/bootstrap/server.go +++ b/bootstrap/server.go @@ -581,6 +581,8 @@ func SelfDeregister() { log.Errorf("Deregister instance error: %s", resp.GetInfo().GetValue()) } } + // wait the async event handler to finish + time.Sleep(5 * time.Second) } // getLocalHost 获取本地IP地址 diff --git a/cache/client.go b/cache/client.go index 8d5f2c18d..a2ae16c1b 100644 --- a/cache/client.go +++ b/cache/client.go @@ -304,9 +304,7 @@ func doClientPage(ret []*model.Client, offset, limit uint32) []*model.Client { endIndex = totalCount } - for i := range ret { - clients = append(clients, ret[i]) - } + clients = append(clients, ret...) sort.Slice(clients, func(i, j int) bool { return clients[i].ModifyTime().After(clients[j].ModifyTime()) diff --git a/common/model/naming.go b/common/model/naming.go index 7a8346459..eb6e03974 100644 --- a/common/model/naming.go +++ b/common/model/naming.go @@ -530,6 +530,15 @@ func (i *InstanceEvent) InjectMetadata(ctx context.Context) { i.MetaData = value.(map[string]string) } +func (i *InstanceEvent) String() string { + if nil == i { + return "nil" + } + hostPortStr := fmt.Sprintf("%s:%d", i.Instance.GetHost().GetValue(), i.Instance.GetPort().GetValue()) + return fmt.Sprintf("InstanceEvent(id=%s, namespace=%s, service=%s, type=%v, instance=%s, healthy=%v)", + i.Id, i.Namespace, i.Service, i.EType, hostPortStr, i.Instance.GetHealthy().GetValue()) +} + // InstanceCount Service instance statistics type InstanceCount struct { // HealthyInstanceCount 健康实例数 diff --git a/service/instance.go b/service/instance.go index c88045016..f708986d2 100644 --- a/service/instance.go +++ b/service/instance.go @@ -114,11 +114,12 @@ func (s *Server) CreateInstance(ctx context.Context, req *api.Instance) *api.Res Name: req.GetService().GetValue(), Namespace: req.GetNamespace().GetValue(), } + instanceProto := data.Proto event := &model.InstanceEvent{ Id: instanceID, Namespace: svc.Namespace, Service: svc.Name, - Instance: &ins, + Instance: instanceProto, EType: model.EventInstanceOnline, CreateTime: time.Time{}, } @@ -127,11 +128,11 @@ func (s *Server) CreateInstance(ctx context.Context, req *api.Instance) *api.Res s.RecordHistory(instanceRecordEntry(ctx, svc, data, model.OCreate)) out := &api.Instance{ Id: ins.GetId(), - Service: req.GetService(), - Namespace: req.GetNamespace(), - VpcId: req.GetVpcId(), - Host: req.GetHost(), - Port: req.GetPort(), + Service: &wrappers.StringValue{Value: svc.Name}, + Namespace: &wrappers.StringValue{Value: svc.Namespace}, + VpcId: instanceProto.GetVpcId(), + Host: instanceProto.GetHost(), + Port: instanceProto.GetPort(), } return api.NewInstanceResponse(api.ExecuteSuccess, out) }