More verbose logging on corredor connection
This commit is contained in:
parent
876d0046bd
commit
7072afff20
@ -20,8 +20,11 @@ import (
|
||||
|
||||
// Corredor standard connector to Corredor service via gRPC
|
||||
func NewConnection(ctx context.Context, opt options.CorredorOpt, logger *zap.Logger) (c *grpc.ClientConn, err error) {
|
||||
log := logger.Named("conn")
|
||||
|
||||
if !opt.Enabled {
|
||||
// Do not connect when script runner is not enabled
|
||||
log.Info("corredor disabled (CORREDOR_ENABLED=false)")
|
||||
return
|
||||
}
|
||||
|
||||
@ -51,6 +54,7 @@ func NewConnection(ctx context.Context, opt options.CorredorOpt, logger *zap.Log
|
||||
// opt.PublicKey = ""
|
||||
if opt.TlsCertEnabled {
|
||||
// Check paths
|
||||
log.Debug("connecting with TLS certificates enabled (CORREDOR_CLIENT_CERTIFICATES_ENABLED=true)")
|
||||
|
||||
for label, path := range paths {
|
||||
if _, err = os.Stat(path); os.IsNotExist(err) {
|
||||
@ -86,6 +90,8 @@ func NewConnection(ctx context.Context, opt options.CorredorOpt, logger *zap.Log
|
||||
|
||||
dialOpts = append(dialOpts, grpc.WithTransportCredentials(crds))
|
||||
} else {
|
||||
log.Debug("connecting without TLS certificates " +
|
||||
"(this is OK if you are using private or internal docker network)")
|
||||
dialOpts = append(dialOpts, grpc.WithInsecure())
|
||||
}
|
||||
|
||||
@ -97,5 +103,7 @@ func NewConnection(ctx context.Context, opt options.CorredorOpt, logger *zap.Log
|
||||
dialOpts = append(dialOpts, grpc.WithBackoffMaxDelay(opt.MaxBackoffDelay))
|
||||
}
|
||||
|
||||
log.Info("connecting to corredor", zap.String("addr", opt.Addr))
|
||||
|
||||
return grpc.DialContext(ctx, opt.Addr, dialOpts...)
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package corredor
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go.uber.org/zap"
|
||||
"math/rand"
|
||||
"net"
|
||||
"sync"
|
||||
@ -22,7 +23,7 @@ func init() {
|
||||
}
|
||||
|
||||
func TestNewConnectionWithDisabled(t *testing.T) {
|
||||
c, err := NewConnection(nil, options.CorredorOpt{Enabled: false}, nil)
|
||||
c, err := NewConnection(nil, options.CorredorOpt{Enabled: false}, zap.NewNop())
|
||||
assert.Nil(t, c)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user