Skip to content

Commit 88102bd

Browse files
authored
Merge branch 'main' into multi-arch-main
2 parents 131a227 + cae095f commit 88102bd

29 files changed

+440
-377
lines changed

cli/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1371,10 +1371,10 @@ func newProvisionerDaemon(
13711371
connector[string(database.ProvisionerTypeTerraform)] = sdkproto.NewDRPCProvisionerClient(terraformClient)
13721372
}
13731373

1374-
return provisionerd.New(func(ctx context.Context) (proto.DRPCProvisionerDaemonClient, error) {
1374+
return provisionerd.New(func(dialCtx context.Context) (proto.DRPCProvisionerDaemonClient, error) {
13751375
// This debounces calls to listen every second. Read the comment
13761376
// in provisionerdserver.go to learn more!
1377-
return coderAPI.CreateInMemoryProvisionerDaemon(ctx, name)
1377+
return coderAPI.CreateInMemoryProvisionerDaemon(dialCtx, name)
13781378
}, &provisionerd.Options{
13791379
Logger: logger.Named(fmt.Sprintf("provisionerd-%s", name)),
13801380
UpdateInterval: time.Second,

coderd/coderd.go

+18-6
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ func compressHandler(h http.Handler) http.Handler {
11741174

11751175
// CreateInMemoryProvisionerDaemon is an in-memory connection to a provisionerd.
11761176
// Useful when starting coderd and provisionerd in the same process.
1177-
func (api *API) CreateInMemoryProvisionerDaemon(ctx context.Context, name string) (client proto.DRPCProvisionerDaemonClient, err error) {
1177+
func (api *API) CreateInMemoryProvisionerDaemon(dialCtx context.Context, name string) (client proto.DRPCProvisionerDaemonClient, err error) {
11781178
tracer := api.TracerProvider.Tracer(tracing.TracerName)
11791179
clientSession, serverSession := drpc.MemTransportPipe()
11801180
defer func() {
@@ -1185,7 +1185,7 @@ func (api *API) CreateInMemoryProvisionerDaemon(ctx context.Context, name string
11851185
}()
11861186

11871187
//nolint:gocritic // in-memory provisioners are owned by system
1188-
daemon, err := api.Database.UpsertProvisionerDaemon(dbauthz.AsSystemRestricted(ctx), database.UpsertProvisionerDaemonParams{
1188+
daemon, err := api.Database.UpsertProvisionerDaemon(dbauthz.AsSystemRestricted(dialCtx), database.UpsertProvisionerDaemonParams{
11891189
Name: name,
11901190
CreatedAt: dbtime.Now(),
11911191
Provisioners: []database.ProvisionerType{
@@ -1201,7 +1201,7 @@ func (api *API) CreateInMemoryProvisionerDaemon(ctx context.Context, name string
12011201
}
12021202

12031203
mux := drpcmux.New()
1204-
api.Logger.Info(ctx, "starting in-memory provisioner daemon", slog.F("name", name))
1204+
api.Logger.Info(dialCtx, "starting in-memory provisioner daemon", slog.F("name", name))
12051205
logger := api.Logger.Named(fmt.Sprintf("inmem-provisionerd-%s", name))
12061206
srv, err := provisionerdserver.NewServer(
12071207
api.ctx, // use the same ctx as the API
@@ -1238,13 +1238,25 @@ func (api *API) CreateInMemoryProvisionerDaemon(ctx context.Context, name string
12381238
if xerrors.Is(err, io.EOF) {
12391239
return
12401240
}
1241-
logger.Debug(ctx, "drpc server error", slog.Error(err))
1241+
logger.Debug(dialCtx, "drpc server error", slog.Error(err))
12421242
},
12431243
},
12441244
)
1245+
// in-mem pipes aren't technically "websockets" but they have the same properties as far as the
1246+
// API is concerned: they are long-lived connections that we need to close before completing
1247+
// shutdown of the API.
1248+
api.WebsocketWaitMutex.Lock()
1249+
api.WebsocketWaitGroup.Add(1)
1250+
api.WebsocketWaitMutex.Unlock()
12451251
go func() {
1246-
err := server.Serve(ctx, serverSession)
1247-
logger.Info(ctx, "provisioner daemon disconnected", slog.Error(err))
1252+
defer api.WebsocketWaitGroup.Done()
1253+
// here we pass the background context, since we want the server to keep serving until the
1254+
// client hangs up. If we, say, pass the API context, then when it is canceled, we could
1255+
// drop a job that we locked in the database but never passed to the provisionerd. The
1256+
// provisionerd is local, in-mem, so there isn't a danger of losing contact with it and
1257+
// having a dead connection we don't know the status of.
1258+
err := server.Serve(context.Background(), serverSession)
1259+
logger.Info(dialCtx, "provisioner daemon disconnected", slog.Error(err))
12481260
// close the sessions, so we don't leak goroutines serving them.
12491261
_ = clientSession.Close()
12501262
_ = serverSession.Close()

coderd/coderdtest/coderdtest.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ func NewProvisionerDaemon(t testing.TB, coderAPI *coderd.API) io.Closer {
532532
assert.NoError(t, err)
533533
}()
534534

535-
daemon := provisionerd.New(func(ctx context.Context) (provisionerdproto.DRPCProvisionerDaemonClient, error) {
536-
return coderAPI.CreateInMemoryProvisionerDaemon(ctx, "test")
535+
daemon := provisionerd.New(func(dialCtx context.Context) (provisionerdproto.DRPCProvisionerDaemonClient, error) {
536+
return coderAPI.CreateInMemoryProvisionerDaemon(dialCtx, "test")
537537
}, &provisionerd.Options{
538538
Logger: coderAPI.Logger.Named("provisionerd").Leveled(slog.LevelDebug),
539539
UpdateInterval: 250 * time.Millisecond,

coderd/workspaceagentsrpc_internal_test.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,21 @@ func TestAgentWebsocketMonitor_BuildOutdated(t *testing.T) {
219219

220220
func TestAgentWebsocketMonitor_SendPings(t *testing.T) {
221221
t.Parallel()
222-
ctx := testutil.Context(t, testutil.WaitShort)
222+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
223+
t.Cleanup(cancel)
223224
fConn := &fakePingerCloser{}
224225
uut := &agentWebsocketMonitor{
225226
pingPeriod: testutil.IntervalFast,
226227
conn: fConn,
227228
}
228-
go uut.sendPings(ctx)
229+
done := make(chan struct{})
230+
go func() {
231+
uut.sendPings(ctx)
232+
close(done)
233+
}()
229234
fConn.requireEventuallyHasPing(t)
235+
cancel()
236+
<-done
230237
lastPing := uut.lastPing.Load()
231238
require.NotNil(t, lastPing)
232239
}

coderd/workspaces_test.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -2147,12 +2147,17 @@ func TestWorkspaceUpdateAutomaticUpdates_OK(t *testing.T) {
21472147
require.Equal(t, codersdk.AutomaticUpdatesAlways, updated.AutomaticUpdates)
21482148

21492149
require.Eventually(t, func() bool {
2150-
return len(auditor.AuditLogs()) >= 9
2151-
}, testutil.WaitShort, testutil.IntervalFast)
2152-
l := auditor.AuditLogs()[8]
2153-
require.Equal(t, database.AuditActionWrite, l.Action)
2154-
require.Equal(t, user.ID, l.UserID)
2155-
require.Equal(t, workspace.ID, l.ResourceID)
2150+
var found bool
2151+
for _, l := range auditor.AuditLogs() {
2152+
if l.Action == database.AuditActionWrite &&
2153+
l.UserID == user.ID &&
2154+
l.ResourceID == workspace.ID {
2155+
found = true
2156+
break
2157+
}
2158+
}
2159+
return found
2160+
}, testutil.WaitShort, testutil.IntervalFast, "did not find expected audit log")
21562161
}
21572162

21582163
func TestUpdateWorkspaceAutomaticUpdates_NotFound(t *testing.T) {

docs/faqs.md

+11
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,14 @@ colima start --arch x86_64 --cpu 4 --memory 8 --disk 10
403403
Colima will show the path to the docker socket so I have a
404404
[Coder template](./docker-code-server/main.tf) that prompts the Coder admin to
405405
enter the docker socket as a Terraform variable.
406+
407+
## Why am I getting this "remote host doesn't meet VS Code Server's prerequisites" error when opening up VSCode remote in a Linux environment?
408+
409+
![VS Code Server prerequisite](https://github.com/coder/coder/assets/10648092/150c5996-18b1-4fae-afd0-be2b386a3239)
410+
411+
It is because, more than likely, the supported OS of either the container image
412+
or VM/VPS doesn't have the proper C libraries to run the VS Code Server. For
413+
instance, Alpine is not supported at all. If so, you need to find a container
414+
image or supported OS for the VS Code Server. For more information on OS
415+
prerequisites for Linux, please look at the VSCode docs.
416+
https://code.visualstudio.com/docs/remote/linux#_local-linux-prerequisites

docs/images/install/ec2.svg

+8
Loading

docs/images/install/eks.svg

+1
Loading

docs/images/install/fly.io.svg

+1
Loading

docs/images/install/gce.svg

+14
Loading

0 commit comments

Comments
 (0)