[ 
https://issues.apache.org/jira/browse/SCB-549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16467106#comment-16467106
 ] 

ASF GitHub Bot commented on SCB-549:
------------------------------------

asifdxtreme closed pull request #341: SCB-549 Do not check the instance 
endpoint whether belong to other service
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/341
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/server/service/instances.go b/server/service/instances.go
index eb945069..0e6e03ab 100644
--- a/server/service/instances.go
+++ b/server/service/instances.go
@@ -70,10 +70,10 @@ func (s *InstanceService) preProcessRegisterInstance(ctx 
context.Context, instan
                                
instance.HealthCheck.Interval*(instance.HealthCheck.Times+1) >= math.MaxInt32 {
                                return scerr.NewError(scerr.ErrInvalidParams, 
"Invalid 'healthCheck' settings in request body.")
                        }
-                       renewalInterval = instance.HealthCheck.Interval
-                       retryTimes = instance.HealthCheck.Times
                case pb.CHECK_BY_PLATFORM:
                        // 默认120s
+                       instance.HealthCheck.Interval = renewalInterval
+                       instance.HealthCheck.Times = retryTimes
                }
        }
 
@@ -182,21 +182,18 @@ func (s *InstanceService) Register(ctx context.Context, 
in *pb.RegisterInstanceR
        // build the request options
        key := apt.GenerateInstanceKey(domainProject, instance.ServiceId, 
instanceId)
        hbKey := apt.GenerateInstanceLeaseKey(domainProject, 
instance.ServiceId, instanceId)
-       cmpBytes := 
util.StringToBytesWithNoCopy(apt.GenerateEndpointsIndexKey(domainProject, 
instance))
+       epKey := 
util.StringToBytesWithNoCopy(apt.GenerateEndpointsIndexKey(domainProject, 
instance))
 
        opts := []registry.PluginOp{
                registry.OpPut(registry.WithStrKey(key), 
registry.WithValue(data),
                        registry.WithLease(leaseID)),
                registry.OpPut(registry.WithStrKey(hbKey), 
registry.WithStrValue(fmt.Sprintf("%d", leaseID)),
                        registry.WithLease(leaseID)),
-               registry.OpPut(registry.WithKey(cmpBytes), 
registry.WithStrValue(instance.ServiceId+"/"+instanceId),
+               registry.OpPut(registry.WithKey(epKey), 
registry.WithStrValue(instance.ServiceId+"/"+instanceId),
                        registry.WithLease(leaseID)),
        }
-       uniqueCmpOpts := []registry.CompareOp{
-               registry.OpCmp(registry.CmpVer(cmpBytes), registry.CMP_EQUAL, 
0),
-       }
 
-       resp, err := backend.Registry().TxnWithCmp(ctx, opts, uniqueCmpOpts, 
nil)
+       _, err = backend.Registry().Txn(ctx, opts)
        if err != nil {
                util.Logger().Errorf(err,
                        "register instance failed, service %s, instanceId %s, 
operator %s: commit data into etcd failed.",
@@ -205,36 +202,6 @@ func (s *InstanceService) Register(ctx context.Context, in 
*pb.RegisterInstanceR
                        Response: 
pb.CreateResponse(scerr.ErrUnavailableBackend, "Commit operations failed."),
                }, err
        }
-       if !resp.Succeeded {
-               // revoke the unused lease
-               defer backend.Registry().LeaseRevoke(ctx, leaseID)
-
-               oldInstanceId, checkErr := serviceUtil.CheckEndPoints(ctx, 
in.Instance)
-               if checkErr != nil {
-                       util.Logger().Errorf(checkErr, "register instance 
failed, service %s, operator %s.",
-                               instanceFlag, remoteIP)
-                       resp := pb.CreateResponseWithSCErr(checkErr)
-                       if checkErr.InternalError() {
-                               return &pb.RegisterInstanceResponse{Response: 
resp}, checkErr
-                       }
-                       return &pb.RegisterInstanceResponse{Response: resp}, nil
-               }
-               if len(oldInstanceId) == 0 {
-                       // re-check and found the older lease was revoked
-                       util.Logger().Errorf(errors.New("instance is 
unregistered at the same time"),
-                               "register instance failed, service %s, operator 
%s.", instanceFlag, remoteIP)
-                       return &pb.RegisterInstanceResponse{
-                               Response: 
pb.CreateResponse(scerr.ErrInvalidParams, "Instance is unregistered at the same 
time"),
-                       }, nil
-               }
-               util.Logger().Warnf(errors.New("instance was registered by 
others"),
-                       "register instance successful, service %s instance %s, 
operator %s.",
-                       instance.ServiceId, oldInstanceId, remoteIP)
-               return &pb.RegisterInstanceResponse{
-                       Response:   pb.CreateResponse(pb.Response_SUCCESS, 
"instance more exist."),
-                       InstanceId: oldInstanceId,
-               }, nil
-       }
 
        if reporter != nil {
                if err := reporter.ReportUsedQuota(ctx); err != nil {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Do not check the instance endpoint whether belong to other service
> ------------------------------------------------------------------
>
>                 Key: SCB-549
>                 URL: https://issues.apache.org/jira/browse/SCB-549
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Service-Center
>            Reporter: little-cui
>            Assignee: little-cui
>            Priority: Major
>             Fix For: service-center-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to