Notify only after third failed self-check
This commit is contained in:
@@ -15,7 +15,15 @@ var (
|
|||||||
|
|
||||||
selfcheckTask *modules.Task
|
selfcheckTask *modules.Task
|
||||||
selfcheckTaskRetryAfter = 10 * time.Second
|
selfcheckTaskRetryAfter = 10 * time.Second
|
||||||
selfCheckIsFailing = abool.New()
|
|
||||||
|
// selfCheckIsFailing holds whether or not the self-check is currently
|
||||||
|
// failing. This helps other failure systems to not make noise when there is
|
||||||
|
// an underlying failure.
|
||||||
|
selfCheckIsFailing = abool.New()
|
||||||
|
|
||||||
|
// selfcheckFails counts how often the self check failed successively.
|
||||||
|
// selfcheckFails is not locked as it is only accessed by the self-check task.
|
||||||
|
selfcheckFails int
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -55,6 +63,7 @@ func selfcheckTaskFunc(ctx context.Context, task *modules.Task) error {
|
|||||||
issue, err := selfcheck(ctx)
|
issue, err := selfcheck(ctx)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
selfCheckIsFailing.UnSet()
|
selfCheckIsFailing.UnSet()
|
||||||
|
selfcheckFails = 0
|
||||||
resetSystemIssue()
|
resetSystemIssue()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -62,14 +71,18 @@ func selfcheckTaskFunc(ctx context.Context, task *modules.Task) error {
|
|||||||
// Log result.
|
// Log result.
|
||||||
if issue != nil {
|
if issue != nil {
|
||||||
selfCheckIsFailing.Set()
|
selfCheckIsFailing.Set()
|
||||||
|
selfcheckFails++
|
||||||
|
|
||||||
log.Errorf("compat: %s", err)
|
log.Errorf("compat: %s", err)
|
||||||
issue.notify(err)
|
if selfcheckFails >= 3 {
|
||||||
|
issue.notify(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Retry quicker when failed.
|
// Retry quicker when failed.
|
||||||
task.Schedule(time.Now().Add(selfcheckTaskRetryAfter))
|
task.Schedule(time.Now().Add(selfcheckTaskRetryAfter))
|
||||||
} else {
|
} else {
|
||||||
selfCheckIsFailing.UnSet()
|
selfCheckIsFailing.UnSet()
|
||||||
|
selfcheckFails = 0
|
||||||
|
|
||||||
// Only log internal errors, but don't notify.
|
// Only log internal errors, but don't notify.
|
||||||
log.Warningf("compat: %s", err)
|
log.Warningf("compat: %s", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user