diff --git a/internal/util/grpcclient/client.go b/internal/util/grpcclient/client.go index 1ff36bde14..933fecab9a 100644 --- a/internal/util/grpcclient/client.go +++ b/internal/util/grpcclient/client.go @@ -527,7 +527,7 @@ func (c *ClientBase[T]) SetSession(sess *sessionutil.Session) { func IsCrossClusterRoutingErr(err error) bool { // GRPC utilizes `status.Status` to encapsulate errors, // hence it is not viable to employ the `errors.Is` for assessment. - return strings.Contains(err.Error(), merr.ErrCrossClusterRouting.Error()) + return strings.Contains(err.Error(), merr.ErrServiceCrossClusterRouting.Error()) } func IsServerIDMismatchErr(err error) bool { diff --git a/pkg/util/interceptor/cluster_interceptor.go b/pkg/util/interceptor/cluster_interceptor.go index e27f90f531..f943f4e468 100644 --- a/pkg/util/interceptor/cluster_interceptor.go +++ b/pkg/util/interceptor/cluster_interceptor.go @@ -43,7 +43,7 @@ func ClusterValidationUnaryServerInterceptor() grpc.UnaryServerInterceptor { } cluster := clusters[0] if cluster != "" && cluster != paramtable.Get().CommonCfg.ClusterPrefix.GetValue() { - return nil, merr.WrapErrCrossClusterRouting(paramtable.Get().CommonCfg.ClusterPrefix.GetValue(), cluster) + return nil, merr.WrapErrServiceCrossClusterRouting(paramtable.Get().CommonCfg.ClusterPrefix.GetValue(), cluster) } return handler(ctx, req) } @@ -64,7 +64,7 @@ func ClusterValidationStreamServerInterceptor() grpc.StreamServerInterceptor { } cluster := clusters[0] if cluster != "" && cluster != paramtable.Get().CommonCfg.ClusterPrefix.GetValue() { - return merr.WrapErrCrossClusterRouting(paramtable.Get().CommonCfg.ClusterPrefix.GetValue(), cluster) + return merr.WrapErrServiceCrossClusterRouting(paramtable.Get().CommonCfg.ClusterPrefix.GetValue(), cluster) } return handler(srv, ss) } diff --git a/pkg/util/interceptor/cluster_interceptor_test.go b/pkg/util/interceptor/cluster_interceptor_test.go index 851e908683..a5bd041f50 100644 --- a/pkg/util/interceptor/cluster_interceptor_test.go +++ b/pkg/util/interceptor/cluster_interceptor_test.go @@ -90,7 +90,7 @@ func TestClusterInterceptor(t *testing.T) { md := metadata.Pairs(ClusterKey, "ins-1") ctx = metadata.NewIncomingContext(context.Background(), md) _, err = interceptor(ctx, req, serverInfo, handler) - assert.ErrorIs(t, err, merr.ErrCrossClusterRouting) + assert.ErrorIs(t, err, merr.ErrServiceCrossClusterRouting) // with same cluster md = metadata.Pairs(ClusterKey, paramtable.Get().CommonCfg.ClusterPrefix.GetValue()) @@ -118,7 +118,7 @@ func TestClusterInterceptor(t *testing.T) { md := metadata.Pairs(ClusterKey, "ins-1") ctx = metadata.NewIncomingContext(context.Background(), md) err = interceptor(nil, newMockSS(ctx), nil, handler) - assert.ErrorIs(t, err, merr.ErrCrossClusterRouting) + assert.ErrorIs(t, err, merr.ErrServiceCrossClusterRouting) // with same cluster md = metadata.Pairs(ClusterKey, paramtable.Get().CommonCfg.ClusterPrefix.GetValue()) diff --git a/pkg/util/merr/errors.go b/pkg/util/merr/errors.go index 685e581894..ca4b05b07d 100644 --- a/pkg/util/merr/errors.go +++ b/pkg/util/merr/errors.go @@ -38,7 +38,7 @@ var ( ErrServiceMemoryLimitExceeded = newMilvusError("memory limit exceeded", 3, false) ErrServiceRequestLimitExceeded = newMilvusError("request limit exceeded", 4, true) ErrServiceInternal = newMilvusError("service internal error", 5, false) // Never return this error out of Milvus - ErrCrossClusterRouting = newMilvusError("cross cluster routing", 6, false) + ErrServiceCrossClusterRouting = newMilvusError("cross cluster routing", 6, false) ErrServiceDiskLimitExceeded = newMilvusError("disk limit exceeded", 7, false) ErrServiceRateLimit = newMilvusError("rate limit exceeded", 8, true) ErrServiceForceDeny = newMilvusError("force deny", 9, false) diff --git a/pkg/util/merr/errors_test.go b/pkg/util/merr/errors_test.go index de77f9a11a..7410977746 100644 --- a/pkg/util/merr/errors_test.go +++ b/pkg/util/merr/errors_test.go @@ -75,7 +75,7 @@ func (s *ErrSuite) TestWrap() { s.ErrorIs(WrapErrServiceMemoryLimitExceeded(110, 100, "MLE"), ErrServiceMemoryLimitExceeded) s.ErrorIs(WrapErrServiceRequestLimitExceeded(100, "too many requests"), ErrServiceRequestLimitExceeded) s.ErrorIs(WrapErrServiceInternal("never throw out"), ErrServiceInternal) - s.ErrorIs(WrapErrCrossClusterRouting("ins-0", "ins-1"), ErrCrossClusterRouting) + s.ErrorIs(WrapErrServiceCrossClusterRouting("ins-0", "ins-1"), ErrServiceCrossClusterRouting) s.ErrorIs(WrapErrServiceDiskLimitExceeded(110, 100, "DLE"), ErrServiceDiskLimitExceeded) s.ErrorIs(WrapErrNodeNotMatch(0, 1, "SIM"), ErrNodeNotMatch) diff --git a/pkg/util/merr/utils.go b/pkg/util/merr/utils.go index 9219e0a592..e0255d6d57 100644 --- a/pkg/util/merr/utils.go +++ b/pkg/util/merr/utils.go @@ -241,8 +241,8 @@ func WrapErrServiceInternal(msg string, others ...string) error { return err } -func WrapErrCrossClusterRouting(expectedCluster, actualCluster string, msg ...string) error { - err := errors.Wrapf(ErrCrossClusterRouting, "expectedCluster=%s, actualCluster=%s", expectedCluster, actualCluster) +func WrapErrServiceCrossClusterRouting(expectedCluster, actualCluster string, msg ...string) error { + err := errors.Wrapf(ErrServiceCrossClusterRouting, "expectedCluster=%s, actualCluster=%s", expectedCluster, actualCluster) if len(msg) > 0 { err = errors.Wrap(err, strings.Join(msg, "; ")) }