Skip to content

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

Merged
brandur merged 2 commits intomasterfrom
bg-elector-use-without-cancel-context
Jun 26, 2024
Merged

elector: resign leadership w/ WithoutCancel ctx, not background#403
brandur merged 2 commits intomasterfrom
bg-elector-use-without-cancel-context

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
@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