fix(octo): don't log ERROR when lease renewal is cancelled on purpose#27
Merged
Conversation
When the hub restarts a supervisor (reconfigure) or shuts down, the run
context is cancelled. If the renew ticker raced ahead of the ctx.Done
branch, acquireLease returned context.Canceled and was logged at ERROR
('octo hub: renew lease failed ... context canceled') with a redundant
cancelRun — alarming noise for an entirely expected, benign event.
Guard with isBenignRenewCancel(ctx, err): when the context is already
done or the error is context.Canceled, return quietly (no ERROR, no
redundant cancel). Real DB failures on a live context still log + cancel.
Test: isBenignRenewCancel is benign for cancelled-ctx / context.Canceled
and not for a real DB error on a live context.
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.
Problem
Observed in the live deployment after the reconfigure-restart fix (#22): when the hub cancels a supervisor (reconfigure or shutdown), the renew ticker can race ahead of the
ctx.Donebranch, soacquireLeasereturnscontext.Canceledand gets logged at ERROR —— with a redundant
cancelRun(). Alarming noise for an entirely expected, benign event.Fix
Guard with
isBenignRenewCancel(ctx, err): when the run context is already done or the error iscontext.Canceled, return quietly (no ERROR log, no redundant cancel). A real DB failure on a live context still logs at ERROR and cancels the run as before.Test
TestIsBenignRenewCancel— benign for cancelled-ctx and for acontext.Cancelederror; not benign for a real DB error on a live context.go vet+go test -raceclean.