X Tutup
Skip to content

Commit 2ee3ce5

Browse files
author
Kazuyoshi Kato
committed
Use insecure.NewCredentials instead of grpc.WithInsecure
grpc.WithInsecure is being deprecated. Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
1 parent 2fb739a commit 2ee3ce5

File tree

7 files changed

+25
-7
lines changed

7 files changed

+25
-7
lines changed

client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import (
6666
"golang.org/x/sync/semaphore"
6767
"google.golang.org/grpc"
6868
"google.golang.org/grpc/backoff"
69+
"google.golang.org/grpc/credentials/insecure"
6970
"google.golang.org/grpc/health/grpc_health_v1"
7071
)
7172

@@ -119,7 +120,7 @@ func New(address string, opts ...ClientOpt) (*Client, error) {
119120
}
120121
gopts := []grpc.DialOption{
121122
grpc.WithBlock(),
122-
grpc.WithInsecure(),
123+
grpc.WithTransportCredentials(insecure.NewCredentials()),
123124
grpc.FailOnNonTempDialError(true),
124125
grpc.WithConnectParams(connParams),
125126
grpc.WithContextDialer(dialer.ContextDialer),

cmd/containerd/command/publish.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/urfave/cli"
3333
"google.golang.org/grpc"
3434
"google.golang.org/grpc/backoff"
35+
"google.golang.org/grpc/credentials/insecure"
3536
)
3637

3738
var publishCommand = cli.Command{
@@ -99,7 +100,7 @@ func connect(address string, d func(gocontext.Context, string) (net.Conn, error)
99100
}
100101
gopts := []grpc.DialOption{
101102
grpc.WithBlock(),
102-
grpc.WithInsecure(),
103+
grpc.WithTransportCredentials(insecure.NewCredentials()),
103104
grpc.WithContextDialer(d),
104105
grpc.FailOnNonTempDialError(true),
105106
grpc.WithConnectParams(connParams),

integration/main_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"github.com/stretchr/testify/require"
4444
exec "golang.org/x/sys/execabs"
4545
"google.golang.org/grpc"
46+
"google.golang.org/grpc/credentials/insecure"
4647
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
4748
)
4849

@@ -405,7 +406,10 @@ func RawRuntimeClient() (runtime.RuntimeServiceClient, error) {
405406
}
406407
ctx, cancel := context.WithTimeout(context.Background(), timeout)
407408
defer cancel()
408-
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithContextDialer(dialer))
409+
conn, err := grpc.DialContext(ctx, addr,
410+
grpc.WithTransportCredentials(insecure.NewCredentials()),
411+
grpc.WithContextDialer(dialer),
412+
)
409413
if err != nil {
410414
return nil, errors.Wrap(err, "failed to connect cri endpoint")
411415
}

integration/remote/remote_image.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"time"
4040

4141
"google.golang.org/grpc"
42+
"google.golang.org/grpc/credentials/insecure"
4243
"k8s.io/klog/v2"
4344

4445
internalapi "github.com/containerd/containerd/integration/cri-api/pkg/apis"
@@ -64,7 +65,11 @@ func NewImageService(endpoint string, connectionTimeout time.Duration) (internal
6465
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
6566
defer cancel()
6667

67-
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithContextDialer(dialer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
68+
conn, err := grpc.DialContext(ctx, addr,
69+
grpc.WithTransportCredentials(insecure.NewCredentials()),
70+
grpc.WithContextDialer(dialer),
71+
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)),
72+
)
6873
if err != nil {
6974
klog.Errorf("Connect remote image service %s failed: %v", addr, err)
7075
return nil, err

integration/remote/remote_runtime.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"time"
4141

4242
"google.golang.org/grpc"
43+
"google.golang.org/grpc/credentials/insecure"
4344
"k8s.io/klog/v2"
4445

4546
internalapi "github.com/containerd/containerd/integration/cri-api/pkg/apis"
@@ -73,7 +74,11 @@ func NewRuntimeService(endpoint string, connectionTimeout time.Duration) (intern
7374
ctx, cancel := context.WithTimeout(context.Background(), connectionTimeout)
7475
defer cancel()
7576

76-
conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithContextDialer(dialer), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)))
77+
conn, err := grpc.DialContext(ctx, addr,
78+
grpc.WithTransportCredentials(insecure.NewCredentials()),
79+
grpc.WithContextDialer(dialer),
80+
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxMsgSize)),
81+
)
7782
if err != nil {
7883
klog.Errorf("Connect remote runtime %s failed: %v", addr, err)
7984
return nil, err

services/server/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import (
5959
"google.golang.org/grpc"
6060
"google.golang.org/grpc/backoff"
6161
"google.golang.org/grpc/credentials"
62+
"google.golang.org/grpc/credentials/insecure"
6263
)
6364

6465
const (
@@ -548,7 +549,7 @@ func (pc *proxyClients) getClient(address string) (*grpc.ClientConn, error) {
548549
Backoff: backoffConfig,
549550
}
550551
gopts := []grpc.DialOption{
551-
grpc.WithInsecure(),
552+
grpc.WithTransportCredentials(insecure.NewCredentials()),
552553
grpc.WithConnectParams(connParams),
553554
grpc.WithContextDialer(dialer.ContextDialer),
554555

tracing/plugin/otlp.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
sdktrace "go.opentelemetry.io/otel/sdk/trace"
3030
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
3131
"google.golang.org/grpc"
32+
"google.golang.org/grpc/credentials/insecure"
3233
)
3334

3435
const exporterPlugin = "otlp"
@@ -45,7 +46,7 @@ func init() {
4546
}
4647
dialOpts := []grpc.DialOption{grpc.WithBlock()}
4748
if cfg.Insecure {
48-
dialOpts = append(dialOpts, grpc.WithInsecure())
49+
dialOpts = append(dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials()))
4950
}
5051

5152
exp, err := otlptracegrpc.New(ic.Context,

0 commit comments

Comments
 (0)
X Tutup