fix: Use an unnamed region instead of erroring for DERP (#3810)

This commit is contained in:
Kyle Carberry
2022-09-01 13:43:52 -05:00
committed by GitHub
parent 5f0b13795a
commit e0cb52ceea

View File

@ -701,7 +701,13 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator *tailnet.Coordi
}
region, found := derpMap.Regions[regionID]
if !found {
return codersdk.WorkspaceAgent{}, xerrors.Errorf("region %d not found in derpmap", regionID)
// It's possible that a workspace agent is using an old DERPMap
// and reports regions that do not exist. If that's the case,
// report the region as unknown!
region = &tailcfg.DERPRegion{
RegionID: regionID,
RegionName: fmt.Sprintf("Unnamed %d", regionID),
}
}
workspaceAgent.DERPLatency[region.RegionName] = codersdk.DERPRegion{
Preferred: node.PreferredDERP == regionID,