Skip to content
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

elector: resign leadership w/ WithoutCancel ctx, not background #403

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

bgentry
Copy link
Contributor

@bgentry bgentry commented Jun 26, 2024

Borrowing an idea from #401, rather than using a background context for a shutdown operation that we don't want to be prematurely immediately cancelled, we can instead use a context.WithoutCancel(ctx) to maintain non-cancel parts of the context.

I also updated logger calls in here to use the Context variants for consitency.

@bgentry bgentry requested a review from brandur June 26, 2024 02:30
@@ -375,14 +375,14 @@ func (e *Elector) attemptResignLoop(ctx context.Context) {

// This does not inherit the parent context because we want to give up leadership
// even during a shutdown. There is no way to short-circuit this.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe tweak this comment a little?

@bgentry bgentry force-pushed the bg-elector-use-without-cancel-context branch from f29d994 to 569ed24 Compare June 26, 2024 02:37
@bgentry bgentry requested a review from brandur June 26, 2024 02:37
@brandur brandur merged commit ba920f6 into master Jun 26, 2024
10 checks passed
@brandur brandur deleted the bg-elector-use-without-cancel-context branch June 26, 2024 03:11
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