@@ -24,9 +24,14 @@ import (
24
24
"github.com/coder/coder/v2/coderd/util/ptr"
25
25
)
26
26
27
+ const (
28
+ warningNodeUsesWebsocket = `Node uses WebSockets because the "Upgrade: DERP" header may be blocked on the load balancer.`
29
+ )
30
+
27
31
// @typescript-generate Report
28
32
type Report struct {
29
- Healthy bool `json:"healthy"`
33
+ Healthy bool `json:"healthy"`
34
+ Warnings []string `json:"warnings"`
30
35
31
36
Regions map [int ]* RegionReport `json:"regions"`
32
37
@@ -39,8 +44,9 @@ type Report struct {
39
44
40
45
// @typescript-generate RegionReport
41
46
type RegionReport struct {
42
- mu sync.Mutex
43
- Healthy bool `json:"healthy"`
47
+ mu sync.Mutex
48
+ Healthy bool `json:"healthy"`
49
+ Warnings []string `json:"warnings"`
44
50
45
51
Region * tailcfg.DERPRegion `json:"region"`
46
52
NodeReports []* NodeReport `json:"node_reports"`
@@ -52,8 +58,10 @@ type NodeReport struct {
52
58
mu sync.Mutex
53
59
clientCounter int
54
60
55
- Healthy bool `json:"healthy"`
56
- Node * tailcfg.DERPNode `json:"node"`
61
+ Healthy bool `json:"healthy"`
62
+ Warnings []string `json:"warnings"`
63
+
64
+ Node * tailcfg.DERPNode `json:"node"`
57
65
58
66
ServerInfo derp.ServerInfoMessage `json:"node_info"`
59
67
CanExchangeMessages bool `json:"can_exchange_messages"`
@@ -108,6 +116,10 @@ func (r *Report) Run(ctx context.Context, opts *ReportOptions) {
108
116
if ! regionReport .Healthy {
109
117
r .Healthy = false
110
118
}
119
+
120
+ for _ , w := range regionReport .Warnings {
121
+ r .Warnings = append (r .Warnings , fmt .Sprintf ("[%s] %s" , regionReport .Region .RegionName , w ))
122
+ }
111
123
mu .Unlock ()
112
124
}()
113
125
}
@@ -159,6 +171,10 @@ func (r *RegionReport) Run(ctx context.Context) {
159
171
if ! nodeReport .Healthy {
160
172
r .Healthy = false
161
173
}
174
+
175
+ for _ , w := range nodeReport .Warnings {
176
+ r .Warnings = append (r .Warnings , fmt .Sprintf ("[%s] %s" , nodeReport .Node .Name , w ))
177
+ }
162
178
r .mu .Unlock ()
163
179
}()
164
180
}
@@ -208,14 +224,14 @@ func (r *NodeReport) Run(ctx context.Context) {
208
224
209
225
// We can't exchange messages with the node,
210
226
if (! r .CanExchangeMessages && ! r .Node .STUNOnly ) ||
211
- // A node may use websockets because `Upgrade: DERP` may be blocked on
212
- // the load balancer. This is unhealthy because websockets are slower
213
- // than the regular DERP protocol.
214
- r .UsesWebsocket ||
215
227
// The node was marked as STUN compatible but the STUN test failed.
216
228
r .STUN .Error != nil {
217
229
r .Healthy = false
218
230
}
231
+
232
+ if r .UsesWebsocket {
233
+ r .Warnings = append (r .Warnings , warningNodeUsesWebsocket )
234
+ }
219
235
}
220
236
221
237
func (r * NodeReport ) doExchangeMessage (ctx context.Context ) {
0 commit comments