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

[dbnode] Default HostID and Discovery config for minimal config #2876

Merged
merged 2 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
46 changes: 37 additions & 9 deletions src/cmd/services/m3dbnode/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ var (
SamplingRate: 1.0,
ExtendedMetrics: &defaultMetricsExtendedMetricsType,
}
defaultListenAddress = "0.0.0.0:9000"
defaultClusterListenAddress = "0.0.0.0:9001"
defaultHTTPNodeListenAddress = "0.0.0.0:9002"
defaultHTTPClusterListenAddress = "0.0.0.0:9003"
defaultDebugListenAddress = "0.0.0.0:9004"
defaultListenAddress = "0.0.0.0:9000"
defaultClusterListenAddress = "0.0.0.0:9001"
defaultHTTPNodeListenAddress = "0.0.0.0:9002"
defaultHTTPClusterListenAddress = "0.0.0.0:9003"
defaultDebugListenAddress = "0.0.0.0:9004"
defaultHostIDValue = "m3db_local"
defaultHostID = hostid.Configuration{
Resolver: hostid.ConfigResolver,
Value: &defaultHostIDValue,
}
defaultGCPercentage = 100
defaultWriteNewSeriesAsync = true
defaultWriteNewSeriesBackoffDuration = 2 * time.Millisecond
Expand All @@ -82,6 +87,10 @@ var (
CalculationType: CalculationTypeFixed,
},
}
defaultDiscoveryType = discovery.M3DBSingleNodeType
defaultDiscovery = discovery.Configuration{
Type: &defaultDiscoveryType,
}
)

// Configuration is the top level configuration that includes both a DB
Expand Down Expand Up @@ -130,7 +139,7 @@ type DBConfiguration struct {
DebugListenAddress *string `yaml:"debugListenAddress"`

// HostID is the local host ID configuration.
HostID hostid.Configuration `yaml:"hostID"`
HostID *hostid.Configuration `yaml:"hostID"`

// Client configuration, used for inter-node communication and when used as a coordinator.
Client client.Configuration `yaml:"client"`
Expand Down Expand Up @@ -166,7 +175,7 @@ type DBConfiguration struct {
PoolingPolicy *PoolingPolicy `yaml:"pooling"`

// The discovery configuration.
DiscoveryConfig discovery.Configuration `yaml:"discovery"`
Discovery *discovery.Configuration `yaml:"discovery"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to change this in a few places as well.


// The configuration for hashing
Hashing HashingConfiguration `yaml:"hashing"`
Expand Down Expand Up @@ -262,6 +271,15 @@ func (c *DBConfiguration) DebugListenAddressOrDefault() string {
return *c.DebugListenAddress
}

// HostIDOrDefault returns the host ID or default.
func (c *DBConfiguration) HostIDOrDefault() hostid.Configuration {
if c.HostID == nil {
return defaultHostID
}

return *c.HostID
}

// CommitLogOrDefault returns the commit log policy or default.
func (c *DBConfiguration) CommitLogOrDefault() CommitLogPolicy {
if c.CommitLog == nil {
Expand Down Expand Up @@ -312,6 +330,15 @@ func (c *DBConfiguration) PoolingPolicyOrDefault() (PoolingPolicy, error) {
return policy, nil
}

// DiscoveryOrDefault returns the discovery configuration or defaults.
func (c *DBConfiguration) DiscoveryOrDefault() discovery.Configuration {
if c.Discovery == nil {
return defaultDiscovery
}

return *c.Discovery
}

// Validate validates the Configuration. We use this method to validate fields
// where the validator package falls short.
func (c *DBConfiguration) Validate() error {
Expand Down Expand Up @@ -589,12 +616,13 @@ func (c *ProtoConfiguration) Validate() error {
func NewEtcdEmbedConfig(cfg DBConfiguration) (*embed.Config, error) {
newKVCfg := embed.NewConfig()

hostID, err := cfg.HostID.Resolve()
hostID, err := cfg.HostIDOrDefault().Resolve()
if err != nil {
return nil, fmt.Errorf("failed resolving hostID %w", err)
}

envCfg, err := cfg.DiscoveryConfig.EnvironmentConfig(hostID)
discoveryCfg := cfg.DiscoveryOrDefault()
envCfg, err := discoveryCfg.EnvironmentConfig(hostID)
if err != nil {
return nil, fmt.Errorf("failed getting env config from discovery config %w", err)
}
Expand Down
7 changes: 0 additions & 7 deletions src/dbnode/config/m3dbnode-local-etcd-proto.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
coordinator: {}

db:
hostID:
resolver: config
value: m3db_local

discovery:
type: m3db_single_node

proto:
enabled: true
schema_registry:
Expand Down
15 changes: 1 addition & 14 deletions src/dbnode/config/m3dbnode-local-etcd.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
coordinator: {}

db:
hostID:
resolver: config
value: m3db_local

discovery:
type: m3db_single_node

# un-comment the lines below to enable Jaeger tracing. See https://www.jaegertracing.io/docs/1.9/getting-started/
# for quick local setup (which this config will send data to).

# tracing:
# backend: jaeger
db: {}