Skip to content

Commit fbe2fa6

Browse files
chore: add test for coord rolling restart (#14680)
Closes coder/internal#50 --------- Co-authored-by: Ethan Dickson <ethan@coder.com>
1 parent 9e63caf commit fbe2fa6

File tree

4 files changed

+348
-6
lines changed

4 files changed

+348
-6
lines changed

coderd/coderd.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -1485,9 +1485,6 @@ func (api *API) Close() error {
14851485
default:
14861486
api.cancel()
14871487
}
1488-
if api.derpCloseFunc != nil {
1489-
api.derpCloseFunc()
1490-
}
14911488

14921489
wsDone := make(chan struct{})
14931490
timer := time.NewTimer(10 * time.Second)
@@ -1513,11 +1510,16 @@ func (api *API) Close() error {
15131510
api.updateChecker.Close()
15141511
}
15151512
_ = api.workspaceAppServer.Close()
1513+
_ = api.agentProvider.Close()
1514+
if api.derpCloseFunc != nil {
1515+
api.derpCloseFunc()
1516+
}
1517+
// The coordinator should be closed after the agent provider, and the DERP
1518+
// handler.
15161519
coordinator := api.TailnetCoordinator.Load()
15171520
if coordinator != nil {
15181521
_ = (*coordinator).Close()
15191522
}
1520-
_ = api.agentProvider.Close()
15211523
_ = api.statsReporter.Close()
15221524
_ = api.NetworkTelemetryBatcher.Close()
15231525
_ = api.OIDCConvertKeyCache.Close()

coderd/tailnet.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ func NewServerTailnet(
7575
// given in this callback, it's only valid while connecting.
7676
if derpServer != nil {
7777
conn.SetDERPRegionDialer(func(_ context.Context, region *tailcfg.DERPRegion) net.Conn {
78-
if !region.EmbeddedRelay {
78+
// Don't set up the embedded relay if we're shutting down
79+
if !region.EmbeddedRelay || ctx.Err() != nil {
7980
return nil
8081
}
8182
logger.Debug(ctx, "connecting to embedded DERP via in-memory pipe")

0 commit comments

Comments
 (0)