Skip to content

libnetwork/networkdb: always shut down memberlist #50115

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

Merged
Merged
Changes from all commits
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
libnetwork/networkdb: always shut down memberlist
Gracefully leaving the memberlist cluster is a best-effort operation.
Failing to successfully broadcast the leave message to a peer should not
prevent NetworkDB from cleaning up the memberlist instance on close. But
that was not the case in practice. Log the error returned from
(*memberlist.Memberlist).Leave instead of returning it and proceed with
shutting down irrespective of whether Leave() returns an error.

Signed-off-by: Cory Snider <[email protected]>
  • Loading branch information
corhere committed May 30, 2025
commit 16ed51d864bed6ec7ddeb6b5cdd498855934a503
4 changes: 2 additions & 2 deletions libnetwork/networkdb/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ func (nDB *NetworkDB) clusterLeave() error {
mlist := nDB.memberlist

if err := nDB.sendNodeEvent(NodeEventTypeLeave); err != nil {
log.G(context.TODO()).Errorf("failed to send node leave: %v", err)
log.G(context.TODO()).WithError(err).Error("failed to send node leave event")
}

if err := mlist.Leave(time.Second); err != nil {
return err
log.G(context.TODO()).WithError(err).Error("failed to broadcast memberlist leave message")
}

// cancel the context
Expand Down
Loading