lib/uplink: ensure it's silent by default (#2676)

This commit is contained in:
Egon Elbre 2019-08-01 14:14:09 +03:00 committed by Stefan Benten
parent 287fdf9936
commit 369a51ed00
15 changed files with 32 additions and 34 deletions

View File

@ -256,17 +256,12 @@ func (flags GatewayFlags) NewGateway(ctx context.Context) (gw minio.Gateway, err
func (flags *GatewayFlags) newUplink(ctx context.Context) (*libuplink.Uplink, error) {
// Transform the gateway config flags to the libuplink config object
libuplinkCfg := &libuplink.Config{}
libuplinkCfg.Volatile.Log = zap.L()
libuplinkCfg.Volatile.MaxInlineSize = flags.Client.MaxInlineSize
libuplinkCfg.Volatile.MaxMemory = flags.RS.MaxBufferMem
libuplinkCfg.Volatile.PeerIDVersion = flags.TLS.PeerIDVersions
libuplinkCfg.Volatile.TLS = struct {
SkipPeerCAWhitelist bool
PeerCAWhitelistPath string
}{
SkipPeerCAWhitelist: !flags.TLS.UsePeerCAWhitelist,
PeerCAWhitelistPath: flags.TLS.PeerCAWhitelistPath,
}
libuplinkCfg.Volatile.TLS.SkipPeerCAWhitelist = !flags.TLS.UsePeerCAWhitelist
libuplinkCfg.Volatile.TLS.PeerCAWhitelistPath = flags.TLS.PeerCAWhitelistPath
libuplinkCfg.Volatile.DialTimeout = flags.Client.DialTimeout
libuplinkCfg.Volatile.RequestTimeout = flags.Client.RequestTimeout

View File

@ -79,17 +79,12 @@ func (cliCfg *UplinkFlags) NewUplink(ctx context.Context) (*libuplink.Uplink, er
// Transform the uplink cli config flags to the libuplink config object
libuplinkCfg := &libuplink.Config{}
libuplinkCfg.Volatile.Log = zap.L()
libuplinkCfg.Volatile.MaxInlineSize = cliCfg.Client.MaxInlineSize
libuplinkCfg.Volatile.MaxMemory = cliCfg.RS.MaxBufferMem
libuplinkCfg.Volatile.PeerIDVersion = cliCfg.TLS.PeerIDVersions
libuplinkCfg.Volatile.TLS = struct {
SkipPeerCAWhitelist bool
PeerCAWhitelistPath string
}{
SkipPeerCAWhitelist: !cliCfg.TLS.UsePeerCAWhitelist,
PeerCAWhitelistPath: cliCfg.TLS.PeerCAWhitelistPath,
}
libuplinkCfg.Volatile.TLS.SkipPeerCAWhitelist = !cliCfg.TLS.UsePeerCAWhitelist
libuplinkCfg.Volatile.TLS.PeerCAWhitelistPath = cliCfg.TLS.PeerCAWhitelistPath
libuplinkCfg.Volatile.DialTimeout = cliCfg.Client.DialTimeout
libuplinkCfg.Volatile.RequestTimeout = cliCfg.Client.RequestTimeout

View File

@ -330,6 +330,7 @@ func atLeastOne(value int) int {
func (client *Uplink) NewLibuplink(ctx context.Context) (*libuplink.Uplink, error) {
config := getDefaultConfig()
libuplinkCfg := &libuplink.Config{}
libuplinkCfg.Volatile.Log = client.Log
libuplinkCfg.Volatile.MaxInlineSize = config.Client.MaxInlineSize
libuplinkCfg.Volatile.MaxMemory = config.RS.MaxBufferMem
libuplinkCfg.Volatile.PeerIDVersion = config.TLS.PeerIDVersions

View File

@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
"storj.io/storj/internal/memory"
"storj.io/storj/internal/testcontext"
@ -72,6 +73,7 @@ func TestPartnerBucketAttrs(t *testing.T) {
t.Run("without partner id", func(t *testing.T) {
config := uplink.Config{}
config.Volatile.Log = zaptest.NewLogger(t)
config.Volatile.TLS.SkipPeerCAWhitelist = true
up, err := uplink.NewUplink(ctx, &config)
@ -93,6 +95,7 @@ func TestPartnerBucketAttrs(t *testing.T) {
t.Run("open with partner id", func(t *testing.T) {
config := uplink.Config{}
config.Volatile.Log = zaptest.NewLogger(t)
config.Volatile.TLS.SkipPeerCAWhitelist = true
config.Volatile.PartnerID = partnerID.String()
@ -115,6 +118,7 @@ func TestPartnerBucketAttrs(t *testing.T) {
t.Run("open with different partner id", func(t *testing.T) {
config := uplink.Config{}
config.Volatile.Log = zaptest.NewLogger(t)
config.Volatile.TLS.SkipPeerCAWhitelist = true
config.Volatile.PartnerID = testrand.UUID().String()

View File

@ -60,8 +60,7 @@ func Example_createBucket() {
// The API key can be created in the web interface
apiKey := "qPSUM3k0bZyOIyil2xrVWiSuc9HuB2yBP3qDrA2Gc"
err := CreateBucketExample(context.Background(), satelliteAddress, apiKey,
&uplink.Config{}, os.Stdout)
err := CreateBucketExample(context.Background(), satelliteAddress, apiKey, &uplink.Config{}, os.Stdout)
if err != nil {
panic(err)
}

View File

@ -8,6 +8,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
"storj.io/storj/internal/testcontext"
"storj.io/storj/internal/testplanet"
@ -21,6 +22,7 @@ func TestBucketExamples(t *testing.T) {
UplinkCount: 1},
func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
cfg := uplink.Config{}
cfg.Volatile.Log = zaptest.NewLogger(t)
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
satelliteAddr := planet.Satellites[0].Local().Address.Address

View File

@ -12,6 +12,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
"storj.io/storj/internal/testcontext"
"storj.io/storj/internal/testplanet"
@ -166,6 +167,7 @@ func runTest(ctx context.Context, t *testing.T, apiKey, satelliteAddr string,
errCatch := func(fn func() error) { require.NoError(t, fn()) }
cfg := &uplink.Config{}
cfg.Volatile.Log = zaptest.NewLogger(t)
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
ul, err := uplink.NewUplink(ctx, cfg)

View File

@ -8,6 +8,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
"storj.io/storj/internal/testcontext"
"storj.io/storj/internal/testplanet"
@ -25,6 +26,7 @@ func TestProjectListBuckets(t *testing.T) {
UplinkCount: 1},
func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
cfg := uplink.Config{}
cfg.Volatile.Log = zaptest.NewLogger(t)
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
satelliteAddr := planet.Satellites[0].Local().Address.Address

View File

@ -92,7 +92,7 @@ func (cfg *Config) setDefaults(ctx context.Context) error {
cfg.Volatile.MaxMemory = 0
}
if cfg.Volatile.Log == nil {
cfg.Volatile.Log = zap.L()
cfg.Volatile.Log = zap.NewNop()
}
if cfg.Volatile.DialTimeout.Seconds() == 0 {
cfg.Volatile.DialTimeout = defaultUplinkDialTimeout

View File

@ -7,6 +7,7 @@ package main
import "C"
import (
"fmt"
libuplink "storj.io/storj/lib/uplink"
"storj.io/storj/pkg/storj"
)

View File

@ -27,6 +27,7 @@ func new_uplink(cfg C.UplinkConfig, cerr **C.char) C.UplinkRef {
scope := rootScope("") // TODO: pass in as argument
libcfg := &uplink.Config{} // TODO: figure out a better name
// TODO: V3-2302, add a way to support logging
libcfg.Volatile.TLS.SkipPeerCAWhitelist = cfg.Volatile.tls.skip_peer_ca_whitelist == C.bool(true)
lib, err := uplink.NewUplink(scope.ctx, libcfg)

View File

@ -276,6 +276,7 @@ func testHandlerRequests(t *testing.T, ctx *testcontext.Context, planet *testpla
func newUplink(ctx context.Context, tb testing.TB) *uplink.Uplink {
cfg := new(uplink.Config)
cfg.Volatile.Log = zaptest.NewLogger(tb)
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
up, err := uplink.NewUplink(ctx, cfg)
require.NoError(tb, err)

View File

@ -46,6 +46,7 @@ func NewUplink(config *Config, tempDir string) (*Uplink, error) {
cfg := &libuplink.Config{}
if config != nil {
// TODO: V3-2303, support logging somehow
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
cfg.Volatile.MaxInlineSize = memory.Size(config.MaxInlineSize)
cfg.Volatile.MaxMemory = memory.Size(config.MaxMemory)

View File

@ -17,6 +17,7 @@ import (
"github.com/minio/minio/pkg/hash"
"github.com/stretchr/testify/assert"
"github.com/vivint/infectious"
"go.uber.org/zap/zaptest"
"storj.io/storj/internal/memory"
"storj.io/storj/internal/testcontext"
@ -648,7 +649,7 @@ func runTest(t *testing.T, test func(context.Context, minio.ObjectLayer, storj.M
planet.Start(ctx)
layer, m, strms, err := initEnv(ctx, planet)
layer, m, strms, err := initEnv(ctx, t, planet)
if !assert.NoError(t, err) {
return
}
@ -656,7 +657,7 @@ func runTest(t *testing.T, test func(context.Context, minio.ObjectLayer, storj.M
test(ctx, layer, m, strms)
}
func initEnv(ctx context.Context, planet *testplanet.Planet) (minio.ObjectLayer, storj.Metainfo, streams.Store, error) {
func initEnv(ctx context.Context, t *testing.T, planet *testplanet.Planet) (minio.ObjectLayer, storj.Metainfo, streams.Store, error) {
// TODO(kaloyan): We should have a better way for configuring the Satellite's API Key
// add project to satisfy constraint
project, err := planet.Satellites[0].DB.Console().Projects().Insert(ctx, &console.Project{
@ -721,12 +722,8 @@ func initEnv(ctx context.Context, planet *testplanet.Planet) (minio.ObjectLayer,
kvm := kvmetainfo.New(p, m, strms, segments, encStore)
cfg := libuplink.Config{}
cfg.Volatile.TLS = struct {
SkipPeerCAWhitelist bool
PeerCAWhitelistPath string
}{
SkipPeerCAWhitelist: true,
}
cfg.Volatile.Log = zaptest.NewLogger(t)
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
uplink, err := libuplink.NewUplink(ctx, &cfg)
if err != nil {

View File

@ -73,6 +73,7 @@ func TestUploadDownload(t *testing.T) {
// bind default values to config
var gwCfg config
cfgstruct.Bind(&pflag.FlagSet{}, &gwCfg, cfgstruct.UseDevDefaults())
var uplinkCfg uplink.Config
cfgstruct.Bind(&pflag.FlagSet{}, &uplinkCfg, cfgstruct.UseDevDefaults())
@ -185,13 +186,9 @@ func runGateway(ctx context.Context, gwCfg config, uplinkCfg uplink.Config, log
}
cfg := libuplink.Config{}
cfg.Volatile.TLS = struct {
SkipPeerCAWhitelist bool
PeerCAWhitelistPath string
}{
SkipPeerCAWhitelist: !uplinkCfg.TLS.UsePeerCAWhitelist,
PeerCAWhitelistPath: uplinkCfg.TLS.PeerCAWhitelistPath,
}
cfg.Volatile.Log = log
cfg.Volatile.TLS.SkipPeerCAWhitelist = !uplinkCfg.TLS.UsePeerCAWhitelist
cfg.Volatile.TLS.PeerCAWhitelistPath = uplinkCfg.TLS.PeerCAWhitelistPath
cfg.Volatile.MaxInlineSize = uplinkCfg.Client.MaxInlineSize
cfg.Volatile.MaxMemory = uplinkCfg.RS.MaxBufferMem