@@ -790,6 +790,11 @@ func (r RetryStage) exec(ctx context.Context, l log.Logger, alerts ...*types.Ale
790
790
case <- ctx .Done ():
791
791
if iErr == nil {
792
792
iErr = ctx .Err ()
793
+ if errors .Is (iErr , context .Canceled ) {
794
+ iErr = NewErrorWithReason (ContextCanceledReason , iErr )
795
+ } else if errors .Is (iErr , context .DeadlineExceeded ) {
796
+ iErr = NewErrorWithReason (ContextDeadlineExceededReason , iErr )
797
+ }
793
798
}
794
799
795
800
return ctx , nil , errors .Wrapf (iErr , "%s/%s: notify retry canceled after %d attempts" , r .groupName , r .integration .String (), i )
@@ -808,14 +813,15 @@ func (r RetryStage) exec(ctx context.Context, l log.Logger, alerts ...*types.Ale
808
813
if ! retry {
809
814
return ctx , alerts , errors .Wrapf (err , "%s/%s: notify retry canceled due to unrecoverable error after %d attempts" , r .groupName , r .integration .String (), i )
810
815
}
811
- if ctx .Err () == nil && (iErr == nil || err .Error () != iErr .Error ()) {
812
- // Log the error if the context isn't done and the error isn't the same as before.
813
- level .Warn (l ).Log ("msg" , "Notify attempt failed, will retry later" , "attempts" , i , "err" , err )
816
+ if ctx .Err () == nil {
817
+ if iErr == nil || err .Error () != iErr .Error () {
818
+ // Log the error if the context isn't done and the error isn't the same as before.
819
+ level .Warn (l ).Log ("msg" , "Notify attempt failed, will retry later" , "attempts" , i , "err" , err )
820
+ }
821
+ // Save this error to be able to return the last seen error by an
822
+ // integration upon context timeout.
823
+ iErr = err
814
824
}
815
-
816
- // Save this error to be able to return the last seen error by an
817
- // integration upon context timeout.
818
- iErr = err
819
825
} else {
820
826
lvl := level .Info (l )
821
827
if i <= 1 {
@@ -828,6 +834,11 @@ func (r RetryStage) exec(ctx context.Context, l log.Logger, alerts ...*types.Ale
828
834
case <- ctx .Done ():
829
835
if iErr == nil {
830
836
iErr = ctx .Err ()
837
+ if errors .Is (iErr , context .Canceled ) {
838
+ iErr = NewErrorWithReason (ContextCanceledReason , iErr )
839
+ } else if errors .Is (iErr , context .DeadlineExceeded ) {
840
+ iErr = NewErrorWithReason (ContextDeadlineExceededReason , iErr )
841
+ }
831
842
}
832
843
833
844
return ctx , nil , errors .Wrapf (iErr , "%s/%s: notify retry canceled after %d attempts" , r .groupName , r .integration .String (), i )
0 commit comments