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

Hide ringpop config validation in ringpop package #4085

Merged
merged 4 commits into from
Mar 23, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions common/membership/config.go

This file was deleted.

42 changes: 0 additions & 42 deletions common/membership/config_test.go

This file was deleted.

7 changes: 5 additions & 2 deletions common/membership/ringpop/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package ringpop
import (
"context"
"crypto/tls"
"errors"
"fmt"
"net"
"sync"
Expand Down Expand Up @@ -70,6 +71,8 @@ type factory struct {
monOnce sync.Once
}

var errMalformedBroadcastAddress = errors.New("ringpop config malformed `broadcastAddress` param")

// newFactory builds a ringpop factory conforming
// to the underlying configuration
func newFactory(
Expand All @@ -82,8 +85,8 @@ func newFactory(
tlsProvider encryption.TLSConfigProvider,
dc *dynamicconfig.Collection,
) (*factory, error) {
if err := membership.ValidateConfig(rpConfig); err != nil {
return nil, err
if rpConfig.BroadcastAddress != "" && net.ParseIP(rpConfig.BroadcastAddress) == nil {
return nil, fmt.Errorf("%w: %s", errMalformedBroadcastAddress, rpConfig.BroadcastAddress)
}
if rpConfig.MaxJoinDuration == 0 {
rpConfig.MaxJoinDuration = defaultMaxJoinDuration
Expand Down
22 changes: 19 additions & 3 deletions common/membership/ringpop/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"go.temporal.io/server/common/config"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/membership"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/primitives"
"go.temporal.io/server/common/rpc/encryption"
Expand Down Expand Up @@ -138,8 +137,6 @@ func (s *RingpopSuite) TestHostsMode() {
s.Nil(err)
s.Equal("1.2.3.4", cfg.BroadcastAddress)
s.Equal(time.Second*30, cfg.MaxJoinDuration)
err = membership.ValidateConfig(&cfg)
s.Nil(err)
f, err := newFactory(&cfg, "test", nil, log.NewNoopLogger(), nil, nil, nil, nil)
s.Nil(err)
s.NotNil(f)
Expand All @@ -151,6 +148,25 @@ broadcastAddress: "1.2.3.4"
maxJoinDuration: 30s`
}

func (s *RingpopSuite) TestInvalidBroadcastAddress() {
cfg := config.Membership{
MaxJoinDuration: time.Minute,
BroadcastAddress: "oopsie",
}
_, err := newFactory(
&cfg,
"test",
nil,
log.NewNoopLogger(),
nil,
nil,
nil,
nil,
)
s.ErrorIs(err, errMalformedBroadcastAddress)
s.ErrorContains(err, "oopsie")
}

func newTestRingpopFactory(
serviceName primitives.ServiceName,
logger log.Logger,
Expand Down
6 changes: 0 additions & 6 deletions temporal/fx.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import (
"go.temporal.io/server/common/headers"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/membership"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/persistence/cassandra"
Expand Down Expand Up @@ -169,11 +168,6 @@ func ServerOptionsProvider(opts []ServerOption) (serverOptionsProvider, error) {
return serverOptionsProvider{}, err
}

err = membership.ValidateConfig(&so.config.Global.Membership)
if err != nil {
return serverOptionsProvider{}, fmt.Errorf("ringpop config validation error: %w", err)
}

stopChan := make(chan interface{})

// Logger
Expand Down