mirror of https://github.com/coder/coder.git
fix: preserve order of node reports in healthcheck (#10835)
This commit is contained in:
parent
60c01555b9
commit
8dd003ba5e
|
@ -11,6 +11,7 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
"golang.org/x/xerrors"
|
||||
"tailscale.com/derp"
|
||||
"tailscale.com/derp/derphttp"
|
||||
|
@ -22,6 +23,7 @@ import (
|
|||
tslogger "tailscale.com/types/logger"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/util/ptr"
|
||||
"github.com/coder/coder/v2/coderd/util/slice"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -183,6 +185,11 @@ func (r *RegionReport) Run(ctx context.Context) {
|
|||
}
|
||||
wg.Wait()
|
||||
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
sortNodeReports(r.NodeReports)
|
||||
|
||||
// Coder allows for 1 unhealthy node in the region, unless there is only 1 node.
|
||||
if len(r.Region.Nodes) == 1 {
|
||||
r.Healthy = healthyNodes == len(r.Region.Nodes)
|
||||
|
@ -492,3 +499,9 @@ func convertError(err error) *string {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func sortNodeReports(reports []*NodeReport) {
|
||||
slices.SortFunc(reports, func(a, b *NodeReport) int {
|
||||
return slice.Ascending(a.Node.Name, b.Node.Name)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -83,7 +83,6 @@ func TestDERP(t *testing.T) {
|
|||
|
||||
t.Run("HealthyWithNodeDegraded", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Skip("https://github.com/coder/coder/issues/10824")
|
||||
|
||||
healthyDerpSrv := derp.NewServer(key.NewNode(), func(format string, args ...any) { t.Logf(format, args...) })
|
||||
defer healthyDerpSrv.Close()
|
||||
|
|
Loading…
Reference in New Issue