Skip to content

cl/sentinel: pass ctx through StartSentinelService → stickToPeers#21786

Open
AskAlexSharov wants to merge 1 commit into
mainfrom
alex/graceful_sleep_36
Open

cl/sentinel: pass ctx through StartSentinelService → stickToPeers#21786
AskAlexSharov wants to merge 1 commit into
mainfrom
alex/graceful_sleep_36

Conversation

@AskAlexSharov

Copy link
Copy Markdown
Collaborator

StartSentinelService was creating its own context.Background(), so the sentinel goroutines had no way to receive shutdown signals.

This PR threads the caller's ctx all the way down:

  • StartSentinelService gains a ctx context.Context first parameter
  • createSentinel forwards it to sentinel.New (which stores it as s.ctx)
  • stickToPeers replaces time.Sleep(3 * time.Minute) with a select on s.ctx.Done(), so the reconnect goroutine exits cleanly when the context is cancelled

`StartSentinelService` now accepts a `context.Context` instead of
creating its own `context.Background()`. The ctx flows into
`createSentinel` → `sentinel.New` (stored as `s.ctx`) and into
`stickToPeers`, which replaces `time.Sleep` with a `select` on
`s.ctx.Done()` so the goroutine exits cleanly on shutdown.

@Giulio2002 Giulio2002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — threads the existing context into Sentinel startup and replaces an uninterruptible sleep with ctx-aware waiting.

@Giulio2002 Giulio2002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — threads the existing context into Sentinel startup and replaces an uninterruptible sleep with ctx-aware waiting.

@Giulio2002 Giulio2002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — small context-plumbing cleanup so the static-peer reconnect loop can stop cleanly on shutdown.

@Giulio2002 Giulio2002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — small context-plumbing cleanup so the static-peer reconnect loop can stop cleanly on shutdown.

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.

2 participants