Skip to content

Commit 96e7013

Browse files
committed
Merge branch 'main' of github.com:coder/coder into bq/disable-user-autocomplete
2 parents 1958a2a + da05bbb commit 96e7013

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3276
-1092
lines changed

.github/workflows/mlc_config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
{
1010
"pattern": "developer.github.com"
1111
},
12+
{
13+
"pattern": "docs.github.com"
14+
},
15+
{
16+
"pattern": "support.google.com"
17+
},
1218
{
1319
"pattern": "tailscale.com"
1420
}

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"promptui",
8989
"protobuf",
9090
"provisionerd",
91+
"provisionerdserver",
9192
"provisionersdk",
9293
"ptty",
9394
"ptys",

agent/apphealth.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"golang.org/x/xerrors"
10+
"github.com/google/uuid"
1011

1112
"cdr.dev/slog"
1213
"github.com/coder/coder/codersdk"
@@ -31,9 +32,9 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.Workspace
3132
}
3233

3334
hasHealthchecksEnabled := false
34-
health := make(map[string]codersdk.WorkspaceAppHealth, 0)
35+
health := make(map[uuid.UUID]codersdk.WorkspaceAppHealth, 0)
3536
for _, app := range apps {
36-
health[app.DisplayName] = app.Health
37+
health[app.ID] = app.Health
3738
if !hasHealthchecksEnabled && app.Health != codersdk.WorkspaceAppHealthDisabled {
3839
hasHealthchecksEnabled = true
3940
}
@@ -46,7 +47,7 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.Workspace
4647

4748
// run a ticker for each app health check.
4849
var mu sync.RWMutex
49-
failures := make(map[string]int, 0)
50+
failures := make(map[uuid.UUID]int, 0)
5051
for _, nextApp := range apps {
5152
if !shouldStartTicker(nextApp) {
5253
continue
@@ -85,21 +86,21 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.Workspace
8586
}()
8687
if err != nil {
8788
mu.Lock()
88-
if failures[app.DisplayName] < int(app.Healthcheck.Threshold) {
89+
if failures[app.ID] < int(app.Healthcheck.Threshold) {
8990
// increment the failure count and keep status the same.
9091
// we will change it when we hit the threshold.
91-
failures[app.DisplayName]++
92+
failures[app.ID]++
9293
} else {
9394
// set to unhealthy if we hit the failure threshold.
9495
// we stop incrementing at the threshold to prevent the failure value from increasing forever.
95-
health[app.DisplayName] = codersdk.WorkspaceAppHealthUnhealthy
96+
health[app.ID] = codersdk.WorkspaceAppHealthUnhealthy
9697
}
9798
mu.Unlock()
9899
} else {
99100
mu.Lock()
100101
// we only need one successful health check to be considered healthy.
101-
health[app.DisplayName] = codersdk.WorkspaceAppHealthHealthy
102-
failures[app.DisplayName] = 0
102+
health[app.ID] = codersdk.WorkspaceAppHealthHealthy
103+
failures[app.ID] = 0
103104
mu.Unlock()
104105
}
105106

@@ -155,7 +156,7 @@ func shouldStartTicker(app codersdk.WorkspaceApp) bool {
155156
return app.Healthcheck.URL != "" && app.Healthcheck.Interval > 0 && app.Healthcheck.Threshold > 0
156157
}
157158

158-
func healthChanged(old map[string]codersdk.WorkspaceAppHealth, new map[string]codersdk.WorkspaceAppHealth) bool {
159+
func healthChanged(old map[uuid.UUID]codersdk.WorkspaceAppHealth, new map[uuid.UUID]codersdk.WorkspaceAppHealth) bool {
159160
for name, newValue := range new {
160161
oldValue, found := old[name]
161162
if !found {
@@ -169,8 +170,8 @@ func healthChanged(old map[string]codersdk.WorkspaceAppHealth, new map[string]co
169170
return false
170171
}
171172

172-
func copyHealth(h1 map[string]codersdk.WorkspaceAppHealth) map[string]codersdk.WorkspaceAppHealth {
173-
h2 := make(map[string]codersdk.WorkspaceAppHealth, 0)
173+
func copyHealth(h1 map[uuid.UUID]codersdk.WorkspaceAppHealth) map[uuid.UUID]codersdk.WorkspaceAppHealth {
174+
h2 := make(map[uuid.UUID]codersdk.WorkspaceAppHealth, 0)
174175
for k, v := range h1 {
175176
h2[k] = v
176177
}

agent/apphealth_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ func TestAppHealth(t *testing.T) {
2727
defer cancel()
2828
apps := []codersdk.WorkspaceApp{
2929
{
30-
DisplayName: "app1",
30+
Slug: "app1",
3131
Healthcheck: codersdk.Healthcheck{},
3232
Health: codersdk.WorkspaceAppHealthDisabled,
3333
},
3434
{
35-
DisplayName: "app2",
35+
Slug: "app2",
3636
Healthcheck: codersdk.Healthcheck{
3737
// URL: We don't set the URL for this test because the setup will
3838
// create a httptest server for us and set it for us.
@@ -69,7 +69,7 @@ func TestAppHealth(t *testing.T) {
6969
defer cancel()
7070
apps := []codersdk.WorkspaceApp{
7171
{
72-
DisplayName: "app2",
72+
Slug: "app2",
7373
Healthcheck: codersdk.Healthcheck{
7474
// URL: We don't set the URL for this test because the setup will
7575
// create a httptest server for us and set it for us.
@@ -102,7 +102,7 @@ func TestAppHealth(t *testing.T) {
102102
defer cancel()
103103
apps := []codersdk.WorkspaceApp{
104104
{
105-
DisplayName: "app2",
105+
Slug: "app2",
106106
Healthcheck: codersdk.Healthcheck{
107107
// URL: We don't set the URL for this test because the setup will
108108
// create a httptest server for us and set it for us.
@@ -137,7 +137,7 @@ func TestAppHealth(t *testing.T) {
137137
defer cancel()
138138
apps := []codersdk.WorkspaceApp{
139139
{
140-
DisplayName: "app2",
140+
Slug: "app2",
141141
Healthcheck: codersdk.Healthcheck{
142142
// URL: We don't set the URL for this test because the setup will
143143
// create a httptest server for us and set it for us.
@@ -185,9 +185,9 @@ func setupAppReporter(ctx context.Context, t *testing.T, apps []codersdk.Workspa
185185
}
186186
postWorkspaceAgentAppHealth := func(_ context.Context, req codersdk.PostWorkspaceAppHealthsRequest) error {
187187
mu.Lock()
188-
for name, health := range req.Healths {
188+
for id, health := range req.Healths {
189189
for i, app := range apps {
190-
if app.DisplayName != name {
190+
if app.ID != id {
191191
continue
192192
}
193193
app.Health = health

0 commit comments

Comments
 (0)