Skip to content

feat(coordinator): support node controller graceful close#733

Merged
mattisonchao merged 23 commits intomainfrom
feat.improve.node.controller
Jul 10, 2025
Merged

feat(coordinator): support node controller graceful close#733
mattisonchao merged 23 commits intomainfrom
feat.improve.node.controller

Conversation

@mattisonchao
Copy link
Copy Markdown
Member

Motivation

Support node controller graceful close.

Modification

  • Move background ping to an extra goroutine.
  • Wait until all the background goroutines finish when closing.

@mattisonchao mattisonchao self-assigned this Jul 3, 2025
@mattisonchao mattisonchao marked this pull request as draft July 3, 2025 14:57
@mattisonchao mattisonchao marked this pull request as ready for review July 4, 2025 06:54
@mattisonchao mattisonchao force-pushed the feat.improve.node.controller branch from 0a9b6b2 to 2e3f605 Compare July 4, 2025 06:57
Copy link
Copy Markdown
Member

@RobertIndie RobertIndie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments

This comment was marked as outdated.

mattisonchao and others added 4 commits July 10, 2025 10:11
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>
@mattisonchao mattisonchao requested a review from Copilot July 10, 2025 02:15

This comment was marked as outdated.

mattisonchao and others added 3 commits July 10, 2025 10:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mattisonchao mattisonchao requested a review from Copilot July 10, 2025 02:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 NodeController to accept a context.Context, manage background goroutines via a WaitGroup, and implement a Close that 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 NopCloser for 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 NopCloser explaining its purpose as a no-op io.Closer to improve discoverability and maintainability.
type NopCloser struct {

@mattisonchao mattisonchao merged commit c82bd85 into main Jul 10, 2025
8 checks passed
@mattisonchao mattisonchao deleted the feat.improve.node.controller branch July 10, 2025 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants