Replace deprecated grpc WithInsecure option (#26226)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/26119/head
congqixia 2023-08-09 13:37:16 +08:00 committed by GitHub
parent eea9197306
commit e13b6b88eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions

View File

@ -39,6 +39,7 @@ import (
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"go.uber.org/zap"
)
@ -378,8 +379,11 @@ func (bct *buildClientTask) Run() {
connectGrpcFunc := func() error {
opts := tracer.GetInterceptorOpts()
log.Debug("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, 30*time.Second)
defer cancel()
conn, err := grpc.DialContext(ctx, bct.sess.Address,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
grpc.WithDisableRetry(),
grpc.WithUnaryInterceptor(
grpc_middleware.ChainUnaryClient(

View File

@ -38,6 +38,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"
@ -971,7 +972,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()
}

View File

@ -30,6 +30,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
@ -78,7 +79,7 @@ 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())
}

View File

@ -32,6 +32,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"
@ -189,7 +190,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(),
@ -229,8 +229,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),