From fd526881be1bf1a0c52073f426657a27fe14a7b3 Mon Sep 17 00:00:00 2001 From: Max Holland Date: Mon, 2 Sep 2024 15:22:38 +0100 Subject: [PATCH] Add nil check for serf The reconcile loop and the startup code which initialises the `c.serf` variable start in parallel so there's a chance for serf to be nil when `MembersFiltered` is called --- cluster/cluster.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cluster/cluster.go b/cluster/cluster.go index 3436ef77..43e86879 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -184,6 +184,9 @@ func (c *ClusterImpl) retryJoin(ctx context.Context) { } func (c *ClusterImpl) MembersFiltered(filter map[string]string, status, name string) ([]Member, error) { + if c.serf == nil { + return nil, fmt.Errorf("serf not initialized") + } return FilterMembers(toClusterMembers(c.serf.Members()), filter, status, name) }