From 259200cc88677185acf0cc69eab48996694497c0 Mon Sep 17 00:00:00 2001 From: Kosuke Morimoto Date: Thu, 12 Sep 2024 14:27:07 +0900 Subject: [PATCH] add check context cancel (#2596) * add check context cancel Signed-off-by: Kosuke Morimoto * fix Signed-off-by: Kosuke Morimoto * fix Signed-off-by: Kosuke Morimoto * fix Signed-off-by: Kosuke Morimoto * fix Signed-off-by: Kosuke Morimoto * fix Signed-off-by: Kosuke Morimoto * fix Signed-off-by: Kosuke Morimoto * fix Signed-off-by: Kosuke Morimoto * update deps Signed-off-by: Kosuke Morimoto --------- Signed-off-by: Kosuke Morimoto Co-authored-by: Yusuke Kato --- internal/backoff/backoff.go | 16 ++++++++++++++++ versions/GO_VERSION | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/backoff/backoff.go b/internal/backoff/backoff.go index 04c1355739d..0c30f6571ec 100644 --- a/internal/backoff/backoff.go +++ b/internal/backoff/backoff.go @@ -186,6 +186,22 @@ func (b *backoff) Do( dur *= b.backoffFactor jdur = b.addJitter(dur) } + if cnt >= b.maxRetryCount-1 { + select { + case <-dctx.Done(): + switch dctx.Err() { + case context.DeadlineExceeded: + log.Debugf("[backoff]\tfor: "+name+",\tDeadline Exceeded\terror: %v", err.Error()) + return nil, errors.ErrBackoffTimeout(err) + case context.Canceled: + log.Debugf("[backoff]\tfor: "+name+",\tCanceled\terror: %v", err.Error()) + return nil, err + default: + return nil, errors.Join(dctx.Err(), err) + } + default: + } + } } } } diff --git a/versions/GO_VERSION b/versions/GO_VERSION index a6c2798a482..49e0a31d496 100644 --- a/versions/GO_VERSION +++ b/versions/GO_VERSION @@ -1 +1 @@ -1.23.0 +1.23.1