Skip to content

Commit

Permalink
Add nil check for serf (#1374)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mjh1 authored Sep 2, 2024
1 parent eaa3c06 commit fdad3c7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit fdad3c7

Please sign in to comment.