Skip to content

Commit

Permalink
Speaker: Allow configuring MemberList timeouts for WAN environments
Browse files Browse the repository at this point in the history
In WAN environments timeouts and intervals for Probes and Gossip in Memberlist can be too tight, since MetalLB uses DefaultLANConfig by default.
New speaker.wanConfig value for the chart allows setting new flag to select DefaultWANConfig "preset" for MemberList instead.

Signed-off-by: Pavel Basov <pbasov@mirantis.com>
  • Loading branch information
Pavel Basov committed Dec 4, 2023
1 parent adfe4cc commit b5213b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions charts/metallb/templates/speaker.yaml
Expand Up @@ -241,6 +241,9 @@ spec:
{{- if .Values.loadBalancerClass }}
- --lb-class={{ .Values.loadBalancerClass }}
{{- end }}
{{- if .Values.speaker.wanConfig }}
- --ml-wan-config
{{- end }}
env:
- name: METALLB_NODE_NAME
valueFrom:
Expand Down
5 changes: 4 additions & 1 deletion internal/speakerlist/speakerlist.go
Expand Up @@ -43,7 +43,7 @@ type SpeakerList struct {
}

// New creates a new SpeakerList and returns a pointer to it.
func New(logger log.Logger, nodeName, bindAddr, bindPort, secret, namespace, labels string, stopCh chan struct{}) (*SpeakerList, error) {
func New(logger log.Logger, nodeName, bindAddr, bindPort, secret, namespace, labels string, WANNetwork bool, stopCh chan struct{}) (*SpeakerList, error) {
sl := SpeakerList{
l: logger,
stopCh: stopCh,
Expand All @@ -57,6 +57,9 @@ func New(logger log.Logger, nodeName, bindAddr, bindPort, secret, namespace, lab
}

mconfig := memberlist.DefaultLANConfig()
if WANNetwork {
mconfig = memberlist.DefaultWANConfig()
}

// mconfig.Name MUST be equal to the spec.nodeName field of the speaker pod as we match it
// against the nodeName field of Endpoint objects inside usableNodes().
Expand Down
3 changes: 2 additions & 1 deletion speaker/main.go
Expand Up @@ -76,6 +76,7 @@ func main() {
mlBindPort = flag.String("ml-bindport", os.Getenv("METALLB_ML_BIND_PORT"), "Bind port for MemberList (fast dead node detection)")
mlLabels = flag.String("ml-labels", os.Getenv("METALLB_ML_LABELS"), "Labels to match the speakers (for MemberList / fast dead node detection)")
mlSecretKeyPath = flag.String("ml-secret-key-path", os.Getenv("METALLB_ML_SECRET_KEY_PATH"), "Path to where the MemberList's secret key is mounted")
mlWANConfig = flag.Bool("ml-wan-config", false, "WAN network type for MemberList default config, bool")
myNode = flag.String("node-name", os.Getenv("METALLB_NODE_NAME"), "name of this Kubernetes node (spec.nodeName)")
port = flag.Int("port", 7472, "HTTP listening port")
logLevel = flag.String("log-level", "info", fmt.Sprintf("log level. must be one of: [%s]", logging.Levels.String()))
Expand Down Expand Up @@ -136,7 +137,7 @@ func main() {
mlSecret = string(mlSecretBytes)
}

sList, err := speakerlist.New(logger, *myNode, *mlBindAddr, *mlBindPort, mlSecret, *namespace, *mlLabels, stopCh)
sList, err := speakerlist.New(logger, *myNode, *mlBindAddr, *mlBindPort, mlSecret, *namespace, *mlLabels, *mlWANConfig, stopCh)
if err != nil {
os.Exit(1)
}
Expand Down

0 comments on commit b5213b6

Please sign in to comment.