|
|
@ -9,6 +9,7 @@ package health
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"os"
|
|
|
|
"sort"
|
|
|
|
"sort"
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
|
"sync/atomic"
|
|
|
|
"sync/atomic"
|
|
|
@ -265,6 +266,8 @@ func OverallError() error {
|
|
|
|
return overallErrorLocked()
|
|
|
|
return overallErrorLocked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fakeErrForTesting = os.Getenv("TS_DEBUG_FAKE_HEALTH_ERROR")
|
|
|
|
|
|
|
|
|
|
|
|
func overallErrorLocked() error {
|
|
|
|
func overallErrorLocked() error {
|
|
|
|
if !anyInterfaceUp {
|
|
|
|
if !anyInterfaceUp {
|
|
|
|
return errors.New("network down")
|
|
|
|
return errors.New("network down")
|
|
|
@ -315,6 +318,9 @@ func overallErrorLocked() error {
|
|
|
|
for regionID, problem := range derpRegionHealthProblem {
|
|
|
|
for regionID, problem := range derpRegionHealthProblem {
|
|
|
|
errs = append(errs, fmt.Errorf("derp%d: %v", regionID, problem))
|
|
|
|
errs = append(errs, fmt.Errorf("derp%d: %v", regionID, problem))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if e := fakeErrForTesting; len(errs) == 0 && e != "" {
|
|
|
|
|
|
|
|
return errors.New(e)
|
|
|
|
|
|
|
|
}
|
|
|
|
sort.Slice(errs, func(i, j int) bool {
|
|
|
|
sort.Slice(errs, func(i, j int) bool {
|
|
|
|
// Not super efficient (stringifying these in a sort), but probably max 2 or 3 items.
|
|
|
|
// Not super efficient (stringifying these in a sort), but probably max 2 or 3 items.
|
|
|
|
return errs[i].Error() < errs[j].Error()
|
|
|
|
return errs[i].Error() < errs[j].Error()
|
|
|
|