Skip to content

Commit 9f4f953

Browse files
authored
fix(coderd/healthcheck): ignore deleted wsproxies in wsproxy healthcheck (#11515)
1 parent e5b9d63 commit 9f4f953

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

coderd/healthcheck/workspaceproxy.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ func (r *WorkspaceProxyReport) Run(ctx context.Context, opts *WorkspaceProxyRepo
7676
return
7777
}
7878

79-
r.WorkspaceProxies = proxies
79+
for _, proxy := range proxies.Regions {
80+
if !proxy.Deleted {
81+
r.WorkspaceProxies.Regions = append(r.WorkspaceProxies.Regions, proxy)
82+
}
83+
}
8084
if r.WorkspaceProxies.Regions == nil {
8185
r.WorkspaceProxies.Regions = make([]codersdk.WorkspaceProxy, 0)
8286
}

coderd/healthcheck/workspaceproxy_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ func TestWorkspaceProxies(t *testing.T) {
164164
expectedSeverity: health.SeverityWarning,
165165
expectedWarningCode: health.CodeProxyUpdate,
166166
},
167+
{
168+
name: "Enabled/OneUnhealthyAndDeleted",
169+
fetchWorkspaceProxies: fakeFetchWorkspaceProxies(fakeWorkspaceProxy("alpha", false, currentVersion, func(wp *codersdk.WorkspaceProxy) {
170+
wp.Deleted = true
171+
})),
172+
updateProxyHealth: fakeUpdateProxyHealth(nil),
173+
expectedHealthy: true,
174+
expectedSeverity: health.SeverityOK,
175+
},
167176
} {
168177
tt := tt
169178
t.Run(tt.name, func(t *testing.T) {
@@ -236,7 +245,7 @@ func (u *fakeWorkspaceProxyFetchUpdater) Update(ctx context.Context) error {
236245
}
237246

238247
//nolint:revive // yes, this is a control flag, and that is OK in a unit test.
239-
func fakeWorkspaceProxy(name string, healthy bool, version string) codersdk.WorkspaceProxy {
248+
func fakeWorkspaceProxy(name string, healthy bool, version string, mutators ...func(*codersdk.WorkspaceProxy)) codersdk.WorkspaceProxy {
240249
var status codersdk.WorkspaceProxyStatus
241250
if !healthy {
242251
status = codersdk.WorkspaceProxyStatus{
@@ -246,14 +255,18 @@ func fakeWorkspaceProxy(name string, healthy bool, version string) codersdk.Work
246255
},
247256
}
248257
}
249-
return codersdk.WorkspaceProxy{
258+
wsp := codersdk.WorkspaceProxy{
250259
Region: codersdk.Region{
251260
Name: name,
252261
Healthy: healthy,
253262
},
254263
Version: version,
255264
Status: status,
256265
}
266+
for _, f := range mutators {
267+
f(&wsp)
268+
}
269+
return wsp
257270
}
258271

259272
func fakeFetchWorkspaceProxies(ps ...codersdk.WorkspaceProxy) func(context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy], error) {

0 commit comments

Comments
 (0)