lib/uplink: ensure it's silent by default (#2676)
This commit is contained in:
parent
287fdf9936
commit
369a51ed00
@ -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) {
|
func (flags *GatewayFlags) newUplink(ctx context.Context) (*libuplink.Uplink, error) {
|
||||||
// Transform the gateway config flags to the libuplink config object
|
// Transform the gateway config flags to the libuplink config object
|
||||||
libuplinkCfg := &libuplink.Config{}
|
libuplinkCfg := &libuplink.Config{}
|
||||||
|
libuplinkCfg.Volatile.Log = zap.L()
|
||||||
libuplinkCfg.Volatile.MaxInlineSize = flags.Client.MaxInlineSize
|
libuplinkCfg.Volatile.MaxInlineSize = flags.Client.MaxInlineSize
|
||||||
libuplinkCfg.Volatile.MaxMemory = flags.RS.MaxBufferMem
|
libuplinkCfg.Volatile.MaxMemory = flags.RS.MaxBufferMem
|
||||||
libuplinkCfg.Volatile.PeerIDVersion = flags.TLS.PeerIDVersions
|
libuplinkCfg.Volatile.PeerIDVersion = flags.TLS.PeerIDVersions
|
||||||
libuplinkCfg.Volatile.TLS = struct {
|
libuplinkCfg.Volatile.TLS.SkipPeerCAWhitelist = !flags.TLS.UsePeerCAWhitelist
|
||||||
SkipPeerCAWhitelist bool
|
libuplinkCfg.Volatile.TLS.PeerCAWhitelistPath = flags.TLS.PeerCAWhitelistPath
|
||||||
PeerCAWhitelistPath string
|
|
||||||
}{
|
|
||||||
SkipPeerCAWhitelist: !flags.TLS.UsePeerCAWhitelist,
|
|
||||||
PeerCAWhitelistPath: flags.TLS.PeerCAWhitelistPath,
|
|
||||||
}
|
|
||||||
|
|
||||||
libuplinkCfg.Volatile.DialTimeout = flags.Client.DialTimeout
|
libuplinkCfg.Volatile.DialTimeout = flags.Client.DialTimeout
|
||||||
libuplinkCfg.Volatile.RequestTimeout = flags.Client.RequestTimeout
|
libuplinkCfg.Volatile.RequestTimeout = flags.Client.RequestTimeout
|
||||||
|
|
||||||
|
@ -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
|
// Transform the uplink cli config flags to the libuplink config object
|
||||||
libuplinkCfg := &libuplink.Config{}
|
libuplinkCfg := &libuplink.Config{}
|
||||||
|
libuplinkCfg.Volatile.Log = zap.L()
|
||||||
libuplinkCfg.Volatile.MaxInlineSize = cliCfg.Client.MaxInlineSize
|
libuplinkCfg.Volatile.MaxInlineSize = cliCfg.Client.MaxInlineSize
|
||||||
libuplinkCfg.Volatile.MaxMemory = cliCfg.RS.MaxBufferMem
|
libuplinkCfg.Volatile.MaxMemory = cliCfg.RS.MaxBufferMem
|
||||||
libuplinkCfg.Volatile.PeerIDVersion = cliCfg.TLS.PeerIDVersions
|
libuplinkCfg.Volatile.PeerIDVersion = cliCfg.TLS.PeerIDVersions
|
||||||
libuplinkCfg.Volatile.TLS = struct {
|
libuplinkCfg.Volatile.TLS.SkipPeerCAWhitelist = !cliCfg.TLS.UsePeerCAWhitelist
|
||||||
SkipPeerCAWhitelist bool
|
libuplinkCfg.Volatile.TLS.PeerCAWhitelistPath = cliCfg.TLS.PeerCAWhitelistPath
|
||||||
PeerCAWhitelistPath string
|
|
||||||
}{
|
|
||||||
SkipPeerCAWhitelist: !cliCfg.TLS.UsePeerCAWhitelist,
|
|
||||||
PeerCAWhitelistPath: cliCfg.TLS.PeerCAWhitelistPath,
|
|
||||||
}
|
|
||||||
|
|
||||||
libuplinkCfg.Volatile.DialTimeout = cliCfg.Client.DialTimeout
|
libuplinkCfg.Volatile.DialTimeout = cliCfg.Client.DialTimeout
|
||||||
libuplinkCfg.Volatile.RequestTimeout = cliCfg.Client.RequestTimeout
|
libuplinkCfg.Volatile.RequestTimeout = cliCfg.Client.RequestTimeout
|
||||||
|
|
||||||
|
@ -330,6 +330,7 @@ func atLeastOne(value int) int {
|
|||||||
func (client *Uplink) NewLibuplink(ctx context.Context) (*libuplink.Uplink, error) {
|
func (client *Uplink) NewLibuplink(ctx context.Context) (*libuplink.Uplink, error) {
|
||||||
config := getDefaultConfig()
|
config := getDefaultConfig()
|
||||||
libuplinkCfg := &libuplink.Config{}
|
libuplinkCfg := &libuplink.Config{}
|
||||||
|
libuplinkCfg.Volatile.Log = client.Log
|
||||||
libuplinkCfg.Volatile.MaxInlineSize = config.Client.MaxInlineSize
|
libuplinkCfg.Volatile.MaxInlineSize = config.Client.MaxInlineSize
|
||||||
libuplinkCfg.Volatile.MaxMemory = config.RS.MaxBufferMem
|
libuplinkCfg.Volatile.MaxMemory = config.RS.MaxBufferMem
|
||||||
libuplinkCfg.Volatile.PeerIDVersion = config.TLS.PeerIDVersions
|
libuplinkCfg.Volatile.PeerIDVersion = config.TLS.PeerIDVersions
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"go.uber.org/zap/zaptest"
|
||||||
|
|
||||||
"storj.io/storj/internal/memory"
|
"storj.io/storj/internal/memory"
|
||||||
"storj.io/storj/internal/testcontext"
|
"storj.io/storj/internal/testcontext"
|
||||||
@ -72,6 +73,7 @@ func TestPartnerBucketAttrs(t *testing.T) {
|
|||||||
|
|
||||||
t.Run("without partner id", func(t *testing.T) {
|
t.Run("without partner id", func(t *testing.T) {
|
||||||
config := uplink.Config{}
|
config := uplink.Config{}
|
||||||
|
config.Volatile.Log = zaptest.NewLogger(t)
|
||||||
config.Volatile.TLS.SkipPeerCAWhitelist = true
|
config.Volatile.TLS.SkipPeerCAWhitelist = true
|
||||||
|
|
||||||
up, err := uplink.NewUplink(ctx, &config)
|
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) {
|
t.Run("open with partner id", func(t *testing.T) {
|
||||||
config := uplink.Config{}
|
config := uplink.Config{}
|
||||||
|
config.Volatile.Log = zaptest.NewLogger(t)
|
||||||
config.Volatile.TLS.SkipPeerCAWhitelist = true
|
config.Volatile.TLS.SkipPeerCAWhitelist = true
|
||||||
config.Volatile.PartnerID = partnerID.String()
|
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) {
|
t.Run("open with different partner id", func(t *testing.T) {
|
||||||
config := uplink.Config{}
|
config := uplink.Config{}
|
||||||
|
config.Volatile.Log = zaptest.NewLogger(t)
|
||||||
config.Volatile.TLS.SkipPeerCAWhitelist = true
|
config.Volatile.TLS.SkipPeerCAWhitelist = true
|
||||||
config.Volatile.PartnerID = testrand.UUID().String()
|
config.Volatile.PartnerID = testrand.UUID().String()
|
||||||
|
|
||||||
|
@ -60,8 +60,7 @@ func Example_createBucket() {
|
|||||||
// The API key can be created in the web interface
|
// The API key can be created in the web interface
|
||||||
apiKey := "qPSUM3k0bZyOIyil2xrVWiSuc9HuB2yBP3qDrA2Gc"
|
apiKey := "qPSUM3k0bZyOIyil2xrVWiSuc9HuB2yBP3qDrA2Gc"
|
||||||
|
|
||||||
err := CreateBucketExample(context.Background(), satelliteAddress, apiKey,
|
err := CreateBucketExample(context.Background(), satelliteAddress, apiKey, &uplink.Config{}, os.Stdout)
|
||||||
&uplink.Config{}, os.Stdout)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"go.uber.org/zap/zaptest"
|
||||||
|
|
||||||
"storj.io/storj/internal/testcontext"
|
"storj.io/storj/internal/testcontext"
|
||||||
"storj.io/storj/internal/testplanet"
|
"storj.io/storj/internal/testplanet"
|
||||||
@ -21,6 +22,7 @@ func TestBucketExamples(t *testing.T) {
|
|||||||
UplinkCount: 1},
|
UplinkCount: 1},
|
||||||
func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||||
cfg := uplink.Config{}
|
cfg := uplink.Config{}
|
||||||
|
cfg.Volatile.Log = zaptest.NewLogger(t)
|
||||||
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
||||||
|
|
||||||
satelliteAddr := planet.Satellites[0].Local().Address.Address
|
satelliteAddr := planet.Satellites[0].Local().Address.Address
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"go.uber.org/zap/zaptest"
|
||||||
|
|
||||||
"storj.io/storj/internal/testcontext"
|
"storj.io/storj/internal/testcontext"
|
||||||
"storj.io/storj/internal/testplanet"
|
"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()) }
|
errCatch := func(fn func() error) { require.NoError(t, fn()) }
|
||||||
|
|
||||||
cfg := &uplink.Config{}
|
cfg := &uplink.Config{}
|
||||||
|
cfg.Volatile.Log = zaptest.NewLogger(t)
|
||||||
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
||||||
|
|
||||||
ul, err := uplink.NewUplink(ctx, cfg)
|
ul, err := uplink.NewUplink(ctx, cfg)
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"go.uber.org/zap/zaptest"
|
||||||
|
|
||||||
"storj.io/storj/internal/testcontext"
|
"storj.io/storj/internal/testcontext"
|
||||||
"storj.io/storj/internal/testplanet"
|
"storj.io/storj/internal/testplanet"
|
||||||
@ -25,6 +26,7 @@ func TestProjectListBuckets(t *testing.T) {
|
|||||||
UplinkCount: 1},
|
UplinkCount: 1},
|
||||||
func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||||
cfg := uplink.Config{}
|
cfg := uplink.Config{}
|
||||||
|
cfg.Volatile.Log = zaptest.NewLogger(t)
|
||||||
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
||||||
|
|
||||||
satelliteAddr := planet.Satellites[0].Local().Address.Address
|
satelliteAddr := planet.Satellites[0].Local().Address.Address
|
||||||
|
@ -92,7 +92,7 @@ func (cfg *Config) setDefaults(ctx context.Context) error {
|
|||||||
cfg.Volatile.MaxMemory = 0
|
cfg.Volatile.MaxMemory = 0
|
||||||
}
|
}
|
||||||
if cfg.Volatile.Log == nil {
|
if cfg.Volatile.Log == nil {
|
||||||
cfg.Volatile.Log = zap.L()
|
cfg.Volatile.Log = zap.NewNop()
|
||||||
}
|
}
|
||||||
if cfg.Volatile.DialTimeout.Seconds() == 0 {
|
if cfg.Volatile.DialTimeout.Seconds() == 0 {
|
||||||
cfg.Volatile.DialTimeout = defaultUplinkDialTimeout
|
cfg.Volatile.DialTimeout = defaultUplinkDialTimeout
|
||||||
|
@ -7,6 +7,7 @@ package main
|
|||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
libuplink "storj.io/storj/lib/uplink"
|
libuplink "storj.io/storj/lib/uplink"
|
||||||
"storj.io/storj/pkg/storj"
|
"storj.io/storj/pkg/storj"
|
||||||
)
|
)
|
||||||
|
@ -27,6 +27,7 @@ func new_uplink(cfg C.UplinkConfig, cerr **C.char) C.UplinkRef {
|
|||||||
scope := rootScope("") // TODO: pass in as argument
|
scope := rootScope("") // TODO: pass in as argument
|
||||||
|
|
||||||
libcfg := &uplink.Config{} // TODO: figure out a better name
|
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)
|
libcfg.Volatile.TLS.SkipPeerCAWhitelist = cfg.Volatile.tls.skip_peer_ca_whitelist == C.bool(true)
|
||||||
|
|
||||||
lib, err := uplink.NewUplink(scope.ctx, libcfg)
|
lib, err := uplink.NewUplink(scope.ctx, libcfg)
|
||||||
|
@ -276,6 +276,7 @@ func testHandlerRequests(t *testing.T, ctx *testcontext.Context, planet *testpla
|
|||||||
|
|
||||||
func newUplink(ctx context.Context, tb testing.TB) *uplink.Uplink {
|
func newUplink(ctx context.Context, tb testing.TB) *uplink.Uplink {
|
||||||
cfg := new(uplink.Config)
|
cfg := new(uplink.Config)
|
||||||
|
cfg.Volatile.Log = zaptest.NewLogger(tb)
|
||||||
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
||||||
up, err := uplink.NewUplink(ctx, cfg)
|
up, err := uplink.NewUplink(ctx, cfg)
|
||||||
require.NoError(tb, err)
|
require.NoError(tb, err)
|
||||||
|
@ -46,6 +46,7 @@ func NewUplink(config *Config, tempDir string) (*Uplink, error) {
|
|||||||
|
|
||||||
cfg := &libuplink.Config{}
|
cfg := &libuplink.Config{}
|
||||||
if config != nil {
|
if config != nil {
|
||||||
|
// TODO: V3-2303, support logging somehow
|
||||||
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
||||||
cfg.Volatile.MaxInlineSize = memory.Size(config.MaxInlineSize)
|
cfg.Volatile.MaxInlineSize = memory.Size(config.MaxInlineSize)
|
||||||
cfg.Volatile.MaxMemory = memory.Size(config.MaxMemory)
|
cfg.Volatile.MaxMemory = memory.Size(config.MaxMemory)
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/minio/minio/pkg/hash"
|
"github.com/minio/minio/pkg/hash"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/vivint/infectious"
|
"github.com/vivint/infectious"
|
||||||
|
"go.uber.org/zap/zaptest"
|
||||||
|
|
||||||
"storj.io/storj/internal/memory"
|
"storj.io/storj/internal/memory"
|
||||||
"storj.io/storj/internal/testcontext"
|
"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)
|
planet.Start(ctx)
|
||||||
|
|
||||||
layer, m, strms, err := initEnv(ctx, planet)
|
layer, m, strms, err := initEnv(ctx, t, planet)
|
||||||
if !assert.NoError(t, err) {
|
if !assert.NoError(t, err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -656,7 +657,7 @@ func runTest(t *testing.T, test func(context.Context, minio.ObjectLayer, storj.M
|
|||||||
test(ctx, layer, m, strms)
|
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
|
// TODO(kaloyan): We should have a better way for configuring the Satellite's API Key
|
||||||
// add project to satisfy constraint
|
// add project to satisfy constraint
|
||||||
project, err := planet.Satellites[0].DB.Console().Projects().Insert(ctx, &console.Project{
|
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)
|
kvm := kvmetainfo.New(p, m, strms, segments, encStore)
|
||||||
|
|
||||||
cfg := libuplink.Config{}
|
cfg := libuplink.Config{}
|
||||||
cfg.Volatile.TLS = struct {
|
cfg.Volatile.Log = zaptest.NewLogger(t)
|
||||||
SkipPeerCAWhitelist bool
|
cfg.Volatile.TLS.SkipPeerCAWhitelist = true
|
||||||
PeerCAWhitelistPath string
|
|
||||||
}{
|
|
||||||
SkipPeerCAWhitelist: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
uplink, err := libuplink.NewUplink(ctx, &cfg)
|
uplink, err := libuplink.NewUplink(ctx, &cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -73,6 +73,7 @@ func TestUploadDownload(t *testing.T) {
|
|||||||
// bind default values to config
|
// bind default values to config
|
||||||
var gwCfg config
|
var gwCfg config
|
||||||
cfgstruct.Bind(&pflag.FlagSet{}, &gwCfg, cfgstruct.UseDevDefaults())
|
cfgstruct.Bind(&pflag.FlagSet{}, &gwCfg, cfgstruct.UseDevDefaults())
|
||||||
|
|
||||||
var uplinkCfg uplink.Config
|
var uplinkCfg uplink.Config
|
||||||
cfgstruct.Bind(&pflag.FlagSet{}, &uplinkCfg, cfgstruct.UseDevDefaults())
|
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 := libuplink.Config{}
|
||||||
cfg.Volatile.TLS = struct {
|
cfg.Volatile.Log = log
|
||||||
SkipPeerCAWhitelist bool
|
cfg.Volatile.TLS.SkipPeerCAWhitelist = !uplinkCfg.TLS.UsePeerCAWhitelist
|
||||||
PeerCAWhitelistPath string
|
cfg.Volatile.TLS.PeerCAWhitelistPath = uplinkCfg.TLS.PeerCAWhitelistPath
|
||||||
}{
|
|
||||||
SkipPeerCAWhitelist: !uplinkCfg.TLS.UsePeerCAWhitelist,
|
|
||||||
PeerCAWhitelistPath: uplinkCfg.TLS.PeerCAWhitelistPath,
|
|
||||||
}
|
|
||||||
cfg.Volatile.MaxInlineSize = uplinkCfg.Client.MaxInlineSize
|
cfg.Volatile.MaxInlineSize = uplinkCfg.Client.MaxInlineSize
|
||||||
cfg.Volatile.MaxMemory = uplinkCfg.RS.MaxBufferMem
|
cfg.Volatile.MaxMemory = uplinkCfg.RS.MaxBufferMem
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user