diff --git a/internal/distributed/connection_manager.go b/internal/distributed/connection_manager.go index 787b338d1e..afe602a2bc 100644 --- a/internal/distributed/connection_manager.go +++ b/internal/distributed/connection_manager.go @@ -38,6 +38,7 @@ import ( "github.com/milvus-io/milvus/internal/util/typeutil" "google.golang.org/grpc" "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" "go.uber.org/zap" ) @@ -221,10 +222,11 @@ func (cm *ConnectionManager) Stop() { } } -//go:norace // fix datarace in unittest // startWatchService will only be invoked at start procedure // otherwise, remove the annotation and add atomic protection +// +//go:norace func (cm *ConnectionManager) processEvent(channel <-chan *sessionutil.SessionEvent) { for { select { @@ -393,8 +395,11 @@ func (bct *buildClientTask) Run() { connectGrpcFunc := func() error { opts := trace.GetInterceptorOpts() log.Info("Grpc connect ", zap.String("Address", bct.sess.Address)) - conn, err := grpc.DialContext(bct.ctx, bct.sess.Address, - grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(30*time.Second), + ctx, cancel := context.WithTimeout(bct.ctx, time.Second*30) + defer cancel() + conn, err := grpc.DialContext(ctx, bct.sess.Address, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithBlock(), grpc.WithDisableRetry(), grpc.WithUnaryInterceptor( grpc_middleware.ChainUnaryClient( diff --git a/internal/distributed/proxy/service_test.go b/internal/distributed/proxy/service_test.go index 4ec65d94d7..b9b4892a9c 100644 --- a/internal/distributed/proxy/service_test.go +++ b/internal/distributed/proxy/service_test.go @@ -36,6 +36,7 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/health/grpc_health_v1" "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" @@ -1140,7 +1141,7 @@ func waitForGrpcReady(opt *WaitOption) { conn.Close() return } - if conn, err := grpc.Dial(address, grpc.WithBlock(), grpc.WithInsecure()); true { + if conn, err := grpc.Dial(address, grpc.WithBlock(), grpc.WithTransportCredentials(insecure.NewCredentials())); true { ch <- err conn.Close() } diff --git a/internal/querycoordv2/session/cluster_test.go b/internal/querycoordv2/session/cluster_test.go index 6f370ae4aa..3b6a592fa3 100644 --- a/internal/querycoordv2/session/cluster_test.go +++ b/internal/querycoordv2/session/cluster_test.go @@ -29,6 +29,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) const bufSize = 1024 * 1024 @@ -76,7 +77,9 @@ func (suite *ClusterTestSuite) setupServers() { // check server ready to serve for _, lis := range suite.listeners { - conn, err := grpc.Dial(lis.Addr().String(), grpc.WithBlock(), grpc.WithInsecure()) + conn, err := grpc.Dial(lis.Addr().String(), + grpc.WithBlock(), + grpc.WithTransportCredentials(insecure.NewCredentials())) suite.NoError(err) suite.NoError(conn.Close()) } diff --git a/internal/util/grpcclient/client.go b/internal/util/grpcclient/client.go index 0db42c883d..f7aa1eb2b9 100644 --- a/internal/util/grpcclient/client.go +++ b/internal/util/grpcclient/client.go @@ -31,6 +31,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/backoff" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" @@ -183,7 +184,6 @@ func (c *ClientBase[T]) connect(ctx context.Context) error { conn, err = grpc.DialContext( dialContext, addr, - //grpc.WithInsecure(), // #nosec G402 grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})), grpc.WithBlock(), @@ -220,8 +220,7 @@ func (c *ClientBase[T]) connect(ctx context.Context) error { conn, err = grpc.DialContext( dialContext, addr, - grpc.WithInsecure(), - //grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})), + grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(), grpc.WithDefaultCallOptions( grpc.MaxCallRecvMsgSize(c.ClientMaxRecvSize),