mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
fix: preserve order of node reports in healthcheck (#10835)
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
"tailscale.com/derp"
|
"tailscale.com/derp"
|
||||||
"tailscale.com/derp/derphttp"
|
"tailscale.com/derp/derphttp"
|
||||||
@ -22,6 +23,7 @@ import (
|
|||||||
tslogger "tailscale.com/types/logger"
|
tslogger "tailscale.com/types/logger"
|
||||||
|
|
||||||
"github.com/coder/coder/v2/coderd/util/ptr"
|
"github.com/coder/coder/v2/coderd/util/ptr"
|
||||||
|
"github.com/coder/coder/v2/coderd/util/slice"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -183,6 +185,11 @@ func (r *RegionReport) Run(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
wg.Wait()
|
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.
|
// Coder allows for 1 unhealthy node in the region, unless there is only 1 node.
|
||||||
if len(r.Region.Nodes) == 1 {
|
if len(r.Region.Nodes) == 1 {
|
||||||
r.Healthy = healthyNodes == len(r.Region.Nodes)
|
r.Healthy = healthyNodes == len(r.Region.Nodes)
|
||||||
@ -492,3 +499,9 @@ func convertError(err error) *string {
|
|||||||
|
|
||||||
return nil
|
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.Run("HealthyWithNodeDegraded", func(t *testing.T) {
|
||||||
t.Parallel()
|
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...) })
|
healthyDerpSrv := derp.NewServer(key.NewNode(), func(format string, args ...any) { t.Logf(format, args...) })
|
||||||
defer healthyDerpSrv.Close()
|
defer healthyDerpSrv.Close()
|
||||||
|
Reference in New Issue
Block a user