fix: allow coderd to start with an empty DERP map when built-in DERP is disabled (#24544)

Allow coderd to start with an empty base DERP map when built-in DERP
is disabled and no static DERP map is configured, so DERP can come from
workspace proxies after startup.

Also add a DERP healthcheck warning when no DERP servers are currently
available at runtime.

Related to: https://linear.app/codercom/issue/PLAT-43/bug-coderd-unable-to-be-started-if-built-in-derp-server-disabled-and
Related to: https://github.com/coder/coder/issues/22324
This commit is contained in:
George K
2026-04-28 09:17:08 -07:00
committed by GitHub
parent 1926b7e658
commit 3f0e015fe5
13 changed files with 125 additions and 70 deletions
+20 -7
View File
@@ -599,13 +599,26 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
defaultRegion = nil
}
derpMap, err := tailnet.NewDERPMap(
ctx, defaultRegion, vals.DERP.Server.STUNAddresses,
vals.DERP.Config.URL.String(), vals.DERP.Config.Path.String(),
vals.DERP.Config.BlockDirect.Value(),
)
if err != nil {
return xerrors.Errorf("create derp map: %w", err)
derpConfigURL := vals.DERP.Config.URL.String()
derpConfigPath := vals.DERP.Config.Path.String()
var derpMap *tailcfg.DERPMap
if defaultRegion == nil && derpConfigURL == "" && derpConfigPath == "" {
logger.Warn(ctx,
"no DERP servers are currently configured; workspace networking"+
" will not work until you either restart coderd with the"+
" built-in DERP server enabled, restart coderd with an"+
" external DERP map configured, or start a workspace proxy"+
" with its DERP server enabled")
derpMap = &tailcfg.DERPMap{Regions: map[int]*tailcfg.DERPRegion{}}
} else {
derpMap, err = tailnet.NewDERPMap(
ctx, defaultRegion, vals.DERP.Server.STUNAddresses,
derpConfigURL, derpConfigPath,
vals.DERP.Config.BlockDirect.Value(),
)
if err != nil {
return xerrors.Errorf("create derp map: %w", err)
}
}
appHostname := vals.WildcardAccessURL.String()
+8 -9
View File
@@ -2370,27 +2370,26 @@ func TestConnectToPostgres(t *testing.T) {
})
}
func TestServer_InvalidDERP(t *testing.T) {
func TestServer_DisabledDERP_EmptyBaseMap(t *testing.T) {
t.Parallel()
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancelFunc()
// Try to start a server with the built-in DERP server disabled and no
// external DERP map.
inv, _ := clitest.New(t,
inv, cfg := clitest.New(t,
"server",
dbArg(t),
"--http-address", ":0",
"--access-url", "http://example.com",
"--derp-server-enable=false",
"--derp-server-stun-addresses", "disable",
"--block-direct-connections",
)
err := inv.Run()
require.Error(t, err)
require.ErrorContains(t, err, "A valid DERP map is required for networking to work")
clitest.Start(t, inv.WithContext(ctx))
waitAccessURL(t, cfg)
}
func TestServer_DisabledDERP(t *testing.T) {
func TestServer_DisabledDERP_ExternalMap(t *testing.T) {
t.Parallel()
derpMap, _ := tailnettest.RunDERPAndSTUN(t)