Skip to content

Commit

Permalink
gossip: move gossip config under cluster
Browse files Browse the repository at this point in the history
Moves 'gossip' config to 'cluster.gossip', since gossip is part of the
cluster configuration.
  • Loading branch information
andydunstall committed Jul 17, 2024
1 parent b592d63 commit edbd451
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 233 deletions.
110 changes: 55 additions & 55 deletions docs/server/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,6 @@ The server supports the following YAML configuration (where most parameters
have corresponding command line flags):

```
cluster:
# A unique identifier for the node in the cluster.
#
# By default a random ID will be generated for the node.
node_id: ""
# A prefix for the node ID.
#
# Piko will generate a unique random identifier for the node and append it to
# the given prefix.
#
# Such as you could use the node or pod name as a prefix, then add a unique
# identifier to ensure the node ID is unique across restarts.
node_id_prefix: ""
# A list of addresses of members in the cluster to join.
#
# This may be either addresses of specific nodes, such as
# '--cluster.join 10.26.104.14,10.26.104.75', or a domain that resolves to
# the addresses of the nodes in the cluster (e.g. a Kubernetes headless
# service), such as '--cluster.join piko.prod-piko-ns'.
#
# Each address must include the host, and may optionally include a port. If no
# port is given, the gossip port of this node is used.
#
# Note each node propagates membership information to the other known nodes,
# so the initial set of configured members only needs to be a subset of nodes.
join: []
# Whether the server node should abort if it is configured with more than one
# node to join (excluding itself) but fails to join any members.
abort_if_join_fails: true
proxy:
# The host/port to listen for incoming proxy connections.
#
Expand Down Expand Up @@ -203,35 +170,68 @@ upstream:
# Path to the PEM encoded key file.
key: ""
gossip:
# The host/port to listen for inter-node gossip traffic.
cluster:
# A unique identifier for the node in the cluster.
#
# If the host is unspecified it defaults to all listeners, such as
# '--gossip.bind-addr :8003' will listen on '0.0.0.0:8003'.
bind_addr: ":8003"
# By default a random ID will be generated for the node.
node_id: ""
# Gossip listen address to advertise to other nodes in the cluster. This is the
# address other nodes will used to gossip with the node.
# A prefix for the node ID.
#
# Such as if the listen address is ':8003', the advertised address may be
# '10.26.104.45:8003' or 'node1.cluster:8003'.
# Piko will generate a unique random identifier for the node and append it to
# the given prefix.
#
# By default, if the bind address includes an IP to bind to that will be used.
# If the bind address does not include an IP (such as ':8003') the nodes
# private IP will be used, such as a bind address of ':8003' may have an
# advertise address of '10.26.104.14:8003'.
advertise_addr: ""
# Such as you could use the node or pod name as a prefix, then add a unique
# identifier to ensure the node ID is unique across restarts.
node_id_prefix: ""
# The interval to initiate rounds of gossip.
# A list of addresses of members in the cluster to join.
#
# Each gossip round selects another known node to synchronize with.`,
interval: 500ms
# The maximum size of any packet sent.
# This may be either addresses of specific nodes, such as
# '--cluster.join 10.26.104.14,10.26.104.75', or a domain that resolves to
# the addresses of the nodes in the cluster (e.g. a Kubernetes headless
# service), such as '--cluster.join piko.prod-piko-ns'.
#
# Depending on your networks MTU you may be able to increase to include more data
# in each packet.
max_packet_size: 1400
# Each address must include the host, and may optionally include a port. If no
# port is given, the gossip port of this node is used.
#
# Note each node propagates membership information to the other known nodes,
# so the initial set of configured members only needs to be a subset of nodes.
join: []
# Whether the server node should abort if it is configured with more than one
# node to join (excluding itself) but fails to join any members.
abort_if_join_fails: true
gossip:
# The host/port to listen for inter-node gossip traffic.
#
# If the host is unspecified it defaults to all listeners, such as
# a bind address of ':8003' will listen on '0.0.0.0:8003'.
bind_addr: ":8003"
# Gossip listen address to advertise to other nodes in the cluster. This is the
# address other nodes will used to gossip with the node.
#
# Such as if the listen address is ':8003', the advertised address may be
# '10.26.104.45:8003' or 'node1.cluster:8003'.
#
# By default, if the bind address includes an IP to bind to that will be used.
# If the bind address does not include an IP (such as ':8003') the nodes
# private IP will be used, such as a bind address of ':8003' may have an
# advertise address of '10.26.104.14:8003'.
advertise_addr: ""
# The interval to initiate rounds of gossip.
#
# Each gossip round selects another known node to synchronize with.`,
interval: 100ms
# The maximum size of any packet sent.
#
# Depending on your networks MTU you may be able to increase to include more data
# in each packet.
max_packet_size: 1400
admin:
# The host/port to listen for incoming admin connections.
Expand Down
10 changes: 5 additions & 5 deletions pikotest/cluster/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ func NewNode(opts ...Option) *Node {
}

conf := config.Default()
conf.Cluster.NodeID = cluster.GenerateNodeID()
conf.Cluster.Join = options.join
conf.Proxy.BindAddr = "127.0.0.1:0"
conf.Upstream.BindAddr = "127.0.0.1:0"
conf.Admin.BindAddr = "127.0.0.1:0"
conf.Gossip.BindAddr = "127.0.0.1:0"
conf.Gossip.Interval = time.Millisecond * 10
conf.Cluster.NodeID = cluster.GenerateNodeID()
conf.Cluster.Join = options.join
conf.Cluster.Gossip.BindAddr = "127.0.0.1:0"
conf.Cluster.Gossip.Interval = time.Millisecond * 10
conf.Proxy.Auth = options.authConfig
conf.Upstream.Auth = options.authConfig
conf.Admin.Auth = options.authConfig
Expand Down Expand Up @@ -123,7 +123,7 @@ func (n *Node) AdminAddr() string {
}

func (n *Node) GossipAddr() string {
return n.server.Config().Gossip.AdvertiseAddr
return n.server.Config().Cluster.Gossip.AdvertiseAddr
}

func (n *Node) ClusterState() *cluster.State {
Expand Down
14 changes: 8 additions & 6 deletions pkg/gossip/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,23 @@ func (c *Config) Validate() error {
return nil
}

func (c *Config) RegisterFlags(fs *pflag.FlagSet) {
func (c *Config) RegisterFlags(fs *pflag.FlagSet, prefix string) {
prefix = prefix + ".gossip."

fs.StringVar(
&c.BindAddr,
"gossip.bind-addr",
prefix+"bind-addr",
c.BindAddr,
`
The host/port to listen for inter-node gossip traffic.
If the host is unspecified it defaults to all listeners, such as
'--gossip.bind-addr :8003' will listen on '0.0.0.0:8003'`,
a bind address ':8003' will listen on '0.0.0.0:8003'`,
)

fs.StringVar(
&c.AdvertiseAddr,
"gossip.advertise-addr",
prefix+"advertise-addr",
c.AdvertiseAddr,
`
Gossip listen address to advertise to other nodes in the cluster. This is the
Expand All @@ -65,7 +67,7 @@ advertise address of '10.26.104.14:8003'.`,

fs.DurationVar(
&c.Interval,
"gossip.interval",
prefix+"interval",
c.Interval,
`
The interval to initiate rounds of gossip.
Expand All @@ -75,7 +77,7 @@ Each gossip round selects another known node to synchronize with.`,

fs.IntVar(
&c.MaxPacketSize,
"gossip.max-packet-size",
prefix+"max-packet-size",
c.MaxPacketSize,
`
The maximum size of any packet sent.
Expand Down
Loading

0 comments on commit edbd451

Please sign in to comment.