Skip to content

fix(coderd/healthcheck): ignore deleted wsproxies in wsproxy healthcheck #11515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion coderd/healthcheck/workspaceproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ func (r *WorkspaceProxyReport) Run(ctx context.Context, opts *WorkspaceProxyRepo
return
}

r.WorkspaceProxies = proxies
for _, proxy := range proxies.Regions {
if !proxy.Deleted {
r.WorkspaceProxies.Regions = append(r.WorkspaceProxies.Regions, proxy)
}
}
if r.WorkspaceProxies.Regions == nil {
r.WorkspaceProxies.Regions = make([]codersdk.WorkspaceProxy, 0)
}
Expand Down
17 changes: 15 additions & 2 deletions coderd/healthcheck/workspaceproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ func TestWorkspaceProxies(t *testing.T) {
expectedSeverity: health.SeverityWarning,
expectedWarningCode: health.CodeProxyUpdate,
},
{
name: "Enabled/OneUnhealthyAndDeleted",
fetchWorkspaceProxies: fakeFetchWorkspaceProxies(fakeWorkspaceProxy("alpha", false, currentVersion, func(wp *codersdk.WorkspaceProxy) {
wp.Deleted = true
})),
updateProxyHealth: fakeUpdateProxyHealth(nil),
expectedHealthy: true,
expectedSeverity: health.SeverityOK,
},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -236,7 +245,7 @@ func (u *fakeWorkspaceProxyFetchUpdater) Update(ctx context.Context) error {
}

//nolint:revive // yes, this is a control flag, and that is OK in a unit test.
func fakeWorkspaceProxy(name string, healthy bool, version string) codersdk.WorkspaceProxy {
func fakeWorkspaceProxy(name string, healthy bool, version string, mutators ...func(*codersdk.WorkspaceProxy)) codersdk.WorkspaceProxy {
var status codersdk.WorkspaceProxyStatus
if !healthy {
status = codersdk.WorkspaceProxyStatus{
Expand All @@ -246,14 +255,18 @@ func fakeWorkspaceProxy(name string, healthy bool, version string) codersdk.Work
},
}
}
return codersdk.WorkspaceProxy{
wsp := codersdk.WorkspaceProxy{
Region: codersdk.Region{
Name: name,
Healthy: healthy,
},
Version: version,
Status: status,
}
for _, f := range mutators {
f(&wsp)
}
return wsp
}

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