Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hubble: replace deprecated usage of grpc.WithInsecure. #25631

Merged
merged 1 commit into from Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions pkg/hubble/peer/types/client.go
Expand Up @@ -52,8 +52,11 @@ type LocalClientBuilder struct {
func (b LocalClientBuilder) Client(target string) (Client, error) {
ctx, cancel := context.WithTimeout(context.Background(), b.DialTimeout)
defer cancel()
// the connection is local so we assume WithInsecure() is safe in this context
conn, err := grpc.DialContext(ctx, target, grpc.WithInsecure(), grpc.WithBlock())
// The connection is local, so we assume using insecure connection is safe in
// this context.
conn, err := grpc.DialContext(ctx, target,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock())
if err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/hubble/relay/pool/client.go
Expand Up @@ -11,6 +11,7 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"

"github.com/cilium/cilium/pkg/crypto/certloader"
poolTypes "github.com/cilium/cilium/pkg/hubble/relay/pool/types"
Expand All @@ -27,7 +28,7 @@ type GRPCClientConnBuilder struct {
Options []grpc.DialOption

// TLSConfig is used to build transport credentials for the connection.
// If not provided, grpc.WithInsecure() is added to Options before creating
// If not provided, insecure credentials are added to Options before creating
// a new ClientConn.
TLSConfig certloader.ClientConfigBuilder
}
Expand All @@ -50,7 +51,7 @@ func (b GRPCClientConnBuilder) ClientConn(target, hostname string) (poolTypes.Cl
copy(opts, b.Options)

if b.TLSConfig == nil {
opts = append(opts, grpc.WithInsecure())
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
} else {
// NOTE: gosec is unable to resolve the constant and warns about "TLS
// MinVersion too low".
Expand Down
3 changes: 2 additions & 1 deletion pkg/hubble/relay/pool/option.go
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/cilium/cilium/pkg/backoff"
peerTypes "github.com/cilium/cilium/pkg/hubble/peer/types"
Expand All @@ -26,7 +27,7 @@ var defaultOptions = options{
clientConnBuilder: GRPCClientConnBuilder{
DialTimeout: defaults.DialTimeout,
Options: []grpc.DialOption{
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
grpc.FailOnNonTempDialError(true),
grpc.WithReturnConnectionError(),
Expand Down