libnetwork/networkdb: always shut down memberlist#50115
Merged
vvoland merged 1 commit intomoby:masterfrom Jun 12, 2025
Merged
Conversation
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 <csnider@mirantis.com>
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that memberlist is always shut down by logging leave errors instead of returning them, preventing resource leaks when a node leaves the cluster.
- Switched
mlist.Leavefailure handling from returning an error to logging it and proceeding with shutdown - Updated
sendNodeEventandmlist.Leavelogs to use structuredWithErrorstyle
Comments suppressed due to low confidence (2)
libnetwork/networkdb/cluster.go:231
- Add a unit or integration test to verify that even if
mlist.Leavereturns an error, the rest ofclusterLeavestill executes and memberlist is cleaned up.
log.G(context.TODO()).WithError(err).Error("failed to broadcast memberlist leave message")
libnetwork/networkdb/cluster.go:231
- [nitpick] Consider using consistent terminology for leave operations (e.g., "leave event" vs. "leave message") to avoid confusion in logs.
log.G(context.TODO()).WithError(err).Error("failed to broadcast memberlist leave message")
robmry
approved these changes
May 30, 2025
vvoland
approved these changes
Jun 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
- What I did
- How I did it
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.
- How to verify it
By inspection.
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)