feat(coordinator): support node controller graceful close#733
Merged
mattisonchao merged 23 commits intomainfrom Jul 10, 2025
Merged
feat(coordinator): support node controller graceful close#733mattisonchao merged 23 commits intomainfrom
mattisonchao merged 23 commits intomainfrom
Conversation
0a9b6b2 to
2e3f605
Compare
RobertIndie
approved these changes
Jul 10, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the node controller to support graceful shutdown by moving health checks and assignment dispatch into dedicated goroutines tied to a context, and waits for them to complete on Close.
- Refactored
NodeControllerto accept acontext.Context, manage background goroutines via aWaitGroup, and implement aClosethat unregisters metrics, cancels work, waits for tasks, and closes the health client. - Updated the coordinator to use the new constructor signature and run controller Close in a background goroutine to avoid deadlocks.
- Adjusted tests and mocks to pass and propagate contexts, and added a
NopCloserfor safe default closure.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| coordinator/coordinator.go | Pass c.ctx into NewNodeController, run Close asynchronously |
| coordinator/controllers/node_controller.go | Major refactor to add context, WaitGroup, atomic closed flag, and graceful Close |
| coordinator/controllers/node_controller_test.go | Updated tests to call the new constructor signature with context |
| coordinator/controllers/mock_test.go | Propagate the test stream’s ctx into Context() |
| common/io/nop_closer.go | Introduced NopCloser to fulfill io.Closer for safe defaults |
Comments suppressed due to low confidence (2)
coordinator/controllers/node_controller_test.go:41
- [nitpick] Add a unit test to verify that
Close()blocks until all background goroutines complete, ensuring the graceful shutdown behavior is exercised.
nc := newNodeController(context.Background(), addr, sap, nal, rpc, 1*time.Second)
common/io/nop_closer.go:21
- [nitpick] Add a brief doc comment above
NopCloserexplaining its purpose as a no-opio.Closerto improve discoverability and maintainability.
type NopCloser struct {
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.
Motivation
Support node controller graceful close.
Modification