Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53802fb

Browse files
committed
Merge branch 'main' into provisionerdaemon
2 parents e87f31d + d76737b commit 53802fb

File tree

13 files changed

+150
-122
lines changed

13 files changed

+150
-122
lines changed

coderd/coderdtest/coderdtest.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ func New(t *testing.T) Server {
119119

120120
pubsub, err = database.NewPubsub(context.Background(), sqlDB, connectionURL)
121121
require.NoError(t, err)
122+
t.Cleanup(func() {
123+
_ = pubsub.Close()
124+
})
122125
}
123126

124127
handler := coderd.New(&coderd.Options{

coderd/workspacehistory_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ func TestWorkspaceHistory(t *testing.T) {
5757
hist, err := client.ProjectHistory(context.Background(), user.Organization, project.Name, projectHistory.Name)
5858
require.NoError(t, err)
5959
return hist.Import.Status.Completed()
60-
}, time.Second, 10*time.Millisecond)
60+
}, 15*time.Second, 50*time.Millisecond)
6161
return projectHistory
6262
}
6363

6464
t.Run("AllHistory", func(t *testing.T) {
6565
t.Parallel()
6666
server := coderdtest.New(t)
67-
_ = server.AddProvisionerd(t)
6867
user := server.RandomInitialUser(t)
68+
_ = server.AddProvisionerd(t)
6969
project, workspace := setupProjectAndWorkspace(t, server.Client, user)
7070
history, err := server.Client.ListWorkspaceHistory(context.Background(), "", workspace.Name)
7171
require.NoError(t, err)
@@ -86,8 +86,8 @@ func TestWorkspaceHistory(t *testing.T) {
8686
t.Run("LatestHistory", func(t *testing.T) {
8787
t.Parallel()
8888
server := coderdtest.New(t)
89-
_ = server.AddProvisionerd(t)
9089
user := server.RandomInitialUser(t)
90+
_ = server.AddProvisionerd(t)
9191
project, workspace := setupProjectAndWorkspace(t, server.Client, user)
9292
_, err := server.Client.WorkspaceHistory(context.Background(), "", workspace.Name, "")
9393
require.Error(t, err)
@@ -106,8 +106,8 @@ func TestWorkspaceHistory(t *testing.T) {
106106
t.Run("CreateHistory", func(t *testing.T) {
107107
t.Parallel()
108108
server := coderdtest.New(t)
109-
_ = server.AddProvisionerd(t)
110109
user := server.RandomInitialUser(t)
110+
_ = server.AddProvisionerd(t)
111111
project, workspace := setupProjectAndWorkspace(t, server.Client, user)
112112
projectHistory := setupProjectHistory(t, server.Client, user, project, map[string]string{
113113
"main.tf": `resource "null_resource" "example" {}`,
@@ -131,8 +131,8 @@ func TestWorkspaceHistory(t *testing.T) {
131131
t.Run("CreateHistoryAlreadyInProgress", func(t *testing.T) {
132132
t.Parallel()
133133
server := coderdtest.New(t)
134-
_ = server.AddProvisionerd(t)
135134
user := server.RandomInitialUser(t)
135+
_ = server.AddProvisionerd(t)
136136
project, workspace := setupProjectAndWorkspace(t, server.Client, user)
137137
projectHistory := setupProjectHistory(t, server.Client, user, project, map[string]string{
138138
"some": "content",
@@ -154,8 +154,8 @@ func TestWorkspaceHistory(t *testing.T) {
154154
t.Run("CreateHistoryInvalidProjectVersion", func(t *testing.T) {
155155
t.Parallel()
156156
server := coderdtest.New(t)
157-
_ = server.AddProvisionerd(t)
158157
user := server.RandomInitialUser(t)
158+
_ = server.AddProvisionerd(t)
159159
_, workspace := setupProjectAndWorkspace(t, server.Client, user)
160160

161161
_, err := server.Client.CreateWorkspaceHistory(context.Background(), "", workspace.Name, coderd.CreateWorkspaceHistoryRequest{

database/query.sql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ WHERE
2929
AND nested.completed_at IS NULL
3030
AND nested.provisioner = ANY(@types :: provisioner_type [ ])
3131
ORDER BY
32-
nested.created FOR
32+
nested.created_at FOR
3333
UPDATE
3434
SKIP LOCKED
3535
LIMIT
@@ -429,11 +429,11 @@ INSERT INTO
429429
project_history_log
430430
SELECT
431431
@project_history_id :: uuid AS project_history_id,
432-
unnset(@id :: uuid [ ]) AS id,
432+
unnest(@id :: uuid [ ]) AS id,
433433
unnest(@created_at :: timestamptz [ ]) AS created_at,
434-
unnset(@source :: log_source [ ]) as source,
435-
unnset(@level :: log_level [ ]) as level,
436-
unnset(@output :: varchar(1024) [ ]) as output RETURNING *;
434+
unnest(@source :: log_source [ ]) as source,
435+
unnest(@level :: log_level [ ]) as level,
436+
unnest(@output :: varchar(1024) [ ]) as output RETURNING *;
437437

438438
-- name: InsertProjectParameter :one
439439
INSERT INTO
@@ -562,12 +562,12 @@ VALUES
562562
INSERT INTO
563563
workspace_history_log
564564
SELECT
565+
unnest(@id :: uuid [ ]) AS id,
565566
@workspace_history_id :: uuid AS workspace_history_id,
566-
unnset(@id :: uuid [ ]) AS id,
567567
unnest(@created_at :: timestamptz [ ]) AS created_at,
568-
unnset(@source :: log_source [ ]) as source,
569-
unnset(@level :: log_level [ ]) as level,
570-
unnset(@output :: varchar(1024) [ ]) as output RETURNING *;
568+
unnest(@source :: log_source [ ]) as source,
569+
unnest(@level :: log_level [ ]) as level,
570+
unnest(@output :: varchar(1024) [ ]) as output RETURNING *;
571571

572572
-- name: InsertWorkspaceResource :one
573573
INSERT INTO

database/query.sql.go

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

develop.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ function create_initial_user() {
1414
# TODO: We need to wait for `coderd` to spin up -
1515
# need to replace with a deterministic strategy
1616
sleep 5s
17-
17+
1818
curl -X POST \
19-
-d "{\"email\": \"$EMAIL\", \"username\": \"$USERNAME\", \"organization\": \"$ORGANIZATION\", \"password\": \"$PASSWORD\"}" \
20-
-H 'Content-Type:application/json' \
21-
http://localhost:3000/api/v2/user
19+
-d "{\"email\": \"$EMAIL\", \"username\": \"$USERNAME\", \"organization\": \"$ORGANIZATION\", \"password\": \"$PASSWORD\"}" \
20+
-H 'Content-Type:application/json' \
21+
http://localhost:3000/api/v2/user
2222
}
2323

2424
# Do initial build - a dev build for coderd.
@@ -29,4 +29,9 @@ make bin/coderd
2929
# This is a way to run multiple processes in parallel, and have Ctrl-C work correctly
3030
# to kill both at the same time. For more details, see:
3131
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
32-
(trap 'kill 0' SIGINT; create_initial_user & CODERV2_HOST=http://127.0.0.1:3000 yarn dev & ./bin/coderd)
32+
(
33+
trap 'kill 0' SIGINT
34+
create_initial_user &
35+
CODERV2_HOST=http://127.0.0.1:3000 yarn --cwd=./site dev &
36+
./bin/coderd
37+
)

go.mod

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module github.com/coder/coder
22

33
go 1.17
44

5-
// Required until https://github.com/hashicorp/terraform-exec/pull/275 is merged.
6-
replace github.com/hashicorp/terraform-exec => github.com/kylecarbs/terraform-exec v0.15.1-0.20220129210610-65894a884c09
5+
// Required until https://github.com/hashicorp/terraform-exec/pull/275 and https://github.com/hashicorp/terraform-exec/pull/276 are merged.
6+
replace github.com/hashicorp/terraform-exec => github.com/kylecarbs/terraform-exec v0.15.1-0.20220202050609-a1ce7181b180
77

88
// Required until https://github.com/hashicorp/terraform-config-inspect/pull/74 is merged.
99
replace github.com/hashicorp/terraform-config-inspect => github.com/kylecarbs/terraform-config-inspect v0.0.0-20211215004401-bbc517866b88
@@ -107,7 +107,6 @@ require (
107107
github.com/zeebo/errs v1.2.2 // indirect
108108
go.opencensus.io v0.23.0 // indirect
109109
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba // indirect
110-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
111110
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
112111
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
113112
golang.org/x/text v0.3.7 // indirect

go.sum

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,9 @@ github.com/gabriel-vasile/mimetype v1.4.0/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmx
432432
github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
433433
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
434434
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
435+
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
435436
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
437+
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
436438
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
437439
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
438440
github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8=
@@ -511,8 +513,11 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe
511513
github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ=
512514
github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0=
513515
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
516+
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
514517
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
518+
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
515519
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
520+
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
516521
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
517522
github.com/gocql/gocql v0.0.0-20210515062232-b7ef815b4556/go.mod h1:DL0ekTmBSTdlNF25Orwt/JMzqIq3EJ4MVa/J/uK64OY=
518523
github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
@@ -640,6 +645,7 @@ github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7
640645
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
641646
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
642647
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
648+
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
643649
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
644650
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
645651
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
@@ -776,6 +782,7 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
776782
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
777783
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
778784
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
785+
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
779786
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
780787
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
781788
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
@@ -824,8 +831,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
824831
github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4=
825832
github.com/kylecarbs/terraform-config-inspect v0.0.0-20211215004401-bbc517866b88 h1:tvG/qs5c4worwGyGnbbb4i/dYYLjpFwDMqcIT3awAf8=
826833
github.com/kylecarbs/terraform-config-inspect v0.0.0-20211215004401-bbc517866b88/go.mod h1:Z0Nnk4+3Cy89smEbrq+sl1bxc9198gIP4I7wcQF6Kqs=
827-
github.com/kylecarbs/terraform-exec v0.15.1-0.20220129210610-65894a884c09 h1:o+8BFGukFfFmGgOJIWEeDXkXRDdFoZ9ndi/GjqnHTGg=
828-
github.com/kylecarbs/terraform-exec v0.15.1-0.20220129210610-65894a884c09/go.mod h1:lRENyXw1BL5V0FCCE8lsW3XoVLRLnxM54jrlYSyXpvM=
834+
github.com/kylecarbs/terraform-exec v0.15.1-0.20220202050609-a1ce7181b180 h1:yafC0pmxjs18fnO5RdKFLSItJIjYwGfSHTfcUvlZb3E=
835+
github.com/kylecarbs/terraform-exec v0.15.1-0.20220202050609-a1ce7181b180/go.mod h1:lRENyXw1BL5V0FCCE8lsW3XoVLRLnxM54jrlYSyXpvM=
829836
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
830837
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
831838
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
@@ -913,9 +920,11 @@ github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXy
913920
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 h1:dcztxKSvZ4Id8iPpHERQBbIJfabdt4wUm5qy3wOL2Zc=
914921
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw=
915922
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
923+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
916924
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
917925
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
918926
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
927+
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
919928
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
920929
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
921930
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
@@ -1172,7 +1181,9 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1
11721181
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
11731182
github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM=
11741183
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
1184+
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
11751185
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
1186+
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
11761187
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
11771188
github.com/unrolled/secure v1.0.9 h1:BWRuEb1vDrBFFDdbCnKkof3gZ35I/bnHGyt0LB0TNyQ=
11781189
github.com/unrolled/secure v1.0.9/go.mod h1:fO+mEan+FLB0CdEnHf6Q4ZZVNqG+5fuLFnP8p0BXDPI=
@@ -1444,7 +1455,6 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
14441455
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
14451456
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
14461457
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1447-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
14481458
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
14491459
golang.org/x/sys v0.0.0-20180224232135-f6cff0780e54/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
14501460
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

peer/conn.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ func (c *Conn) init() error {
145145

146146
c.rtc.OnNegotiationNeeded(c.negotiate)
147147
c.rtc.OnICEConnectionStateChange(func(iceConnectionState webrtc.ICEConnectionState) {
148+
if c.isClosed() {
149+
return
150+
}
151+
148152
c.opts.Logger.Debug(context.Background(), "ice connection state updated",
149153
slog.F("state", iceConnectionState))
150154

provisionerd/provisionerd.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (p *provisionerDaemon) connect(ctx context.Context) {
141141
defer ticker.Stop()
142142
for {
143143
select {
144-
case <-p.closed:
144+
case <-ctx.Done():
145145
return
146146
case <-p.updateStream.Context().Done():
147147
return
@@ -196,6 +196,11 @@ func (p *provisionerDaemon) isRunningJob() bool {
196196
}
197197

198198
func (p *provisionerDaemon) runJob(ctx context.Context) {
199+
// Prevents p.updateStream from being accessed and
200+
// written to at the same time.
201+
p.connectMutex.Lock()
202+
defer p.connectMutex.Unlock()
203+
199204
go func() {
200205
ticker := time.NewTicker(p.opts.UpdateInterval)
201206
defer ticker.Stop()
@@ -214,12 +219,7 @@ func (p *provisionerDaemon) runJob(ctx context.Context) {
214219
}
215220
}
216221
}()
217-
go func() {
218-
select {
219-
case <-p.closed:
220-
case <-ctx.Done():
221-
}
222-
222+
defer func() {
223223
// Cleanup the work directory after execution.
224224
err := os.RemoveAll(p.opts.WorkDirectory)
225225
if err != nil {
@@ -457,6 +457,9 @@ func (p *provisionerDaemon) runWorkspaceProvision(ctx context.Context, provision
457457
}
458458

459459
func (p *provisionerDaemon) cancelActiveJob(errMsg string) {
460+
if p.isClosed() {
461+
return
462+
}
460463
if !p.isRunningJob() {
461464
p.opts.Logger.Warn(context.Background(), "skipping job cancel; none running", slog.F("error_message", errMsg))
462465
return

site/dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (process.env.CODERV2_HOST) {
1717

1818
console.log(`Using CODERV2_HOST: ${coderV2Host}`)
1919

20-
const app = next({ dev, dir: "./site" })
20+
const app = next({ dev, dir: "." })
2121
const handle = app.getRequestHandler()
2222

2323
app

site/jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ module.exports = {
3131
"<rootDir>/**/*.ts",
3232
"<rootDir>/**/*.tsx",
3333
"!<rootDir>/**/*.stories.tsx",
34+
"!<rootDir>/_jest/**/*.*",
3435
"!<rootDir>/.next/**/*.*",
3536
"!<rootDir>/api.ts",
37+
"!<rootDir>/coverage/**/*.*",
3638
"!<rootDir>/dev.ts",
39+
"!<rootDir>/jest-runner.eslint.config.js",
40+
"!<rootDir>/jest.config.js",
3741
"!<rootDir>/next-env.d.ts",
3842
"!<rootDir>/next.config.js",
3943
"!<rootDir>/out/**/*.*",

site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"http-proxy-middleware": "2.0.2",
4545
"jest": "27.4.7",
4646
"jest-runner-eslint": "1.0.0",
47-
"next": "12.0.9",
47+
"next": "12.0.10",
4848
"next-router-mock": "^0.6.5",
4949
"prettier": "2.5.1",
5050
"react": "17.0.2",

0 commit comments

Comments
 (0)