Skip to content

Commit 8dd003b

Browse files
authored
fix: preserve order of node reports in healthcheck (#10835)
1 parent 60c0155 commit 8dd003b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

coderd/healthcheck/derphealth/derp.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"sync/atomic"
1212
"time"
1313

14+
"golang.org/x/exp/slices"
1415
"golang.org/x/xerrors"
1516
"tailscale.com/derp"
1617
"tailscale.com/derp/derphttp"
@@ -22,6 +23,7 @@ import (
2223
tslogger "tailscale.com/types/logger"
2324

2425
"github.com/coder/coder/v2/coderd/util/ptr"
26+
"github.com/coder/coder/v2/coderd/util/slice"
2527
)
2628

2729
const (
@@ -183,6 +185,11 @@ func (r *RegionReport) Run(ctx context.Context) {
183185
}
184186
wg.Wait()
185187

188+
r.mu.Lock()
189+
defer r.mu.Unlock()
190+
191+
sortNodeReports(r.NodeReports)
192+
186193
// Coder allows for 1 unhealthy node in the region, unless there is only 1 node.
187194
if len(r.Region.Nodes) == 1 {
188195
r.Healthy = healthyNodes == len(r.Region.Nodes)
@@ -492,3 +499,9 @@ func convertError(err error) *string {
492499

493500
return nil
494501
}
502+
503+
func sortNodeReports(reports []*NodeReport) {
504+
slices.SortFunc(reports, func(a, b *NodeReport) int {
505+
return slice.Ascending(a.Node.Name, b.Node.Name)
506+
})
507+
}

coderd/healthcheck/derphealth/derp_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ func TestDERP(t *testing.T) {
8383

8484
t.Run("HealthyWithNodeDegraded", func(t *testing.T) {
8585
t.Parallel()
86-
t.Skip("https://github.com/coder/coder/issues/10824")
8786

8887
healthyDerpSrv := derp.NewServer(key.NewNode(), func(format string, args ...any) { t.Logf(format, args...) })
8988
defer healthyDerpSrv.Close()

0 commit comments

Comments
 (0)