chore: replace wsconncache with a single tailnet (#8176)

This commit is contained in:
Colin Adler
2023-07-12 17:37:31 -05:00
committed by GitHub
parent 0a37dd20d6
commit c47b78c44b
36 changed files with 2004 additions and 763 deletions

View File

@ -364,8 +364,23 @@ func New(options *Options) *API {
}
api.Auditor.Store(&options.Auditor)
api.workspaceAgentCache = wsconncache.New(api.dialWorkspaceAgentTailnet, 0)
api.TailnetCoordinator.Store(&options.TailnetCoordinator)
if api.Experiments.Enabled(codersdk.ExperimentSingleTailnet) {
api.agentProvider, err = NewServerTailnet(api.ctx,
options.Logger,
options.DERPServer,
options.DERPMap,
&api.TailnetCoordinator,
wsconncache.New(api._dialWorkspaceAgentTailnet, 0),
)
if err != nil {
panic("failed to setup server tailnet: " + err.Error())
}
} else {
api.agentProvider = &wsconncache.AgentProvider{
Cache: wsconncache.New(api._dialWorkspaceAgentTailnet, 0),
}
}
api.workspaceAppServer = &workspaceapps.Server{
Logger: options.Logger.Named("workspaceapps"),
@ -377,7 +392,7 @@ func New(options *Options) *API {
RealIPConfig: options.RealIPConfig,
SignedTokenProvider: api.WorkspaceAppsProvider,
WorkspaceConnCache: api.workspaceAgentCache,
AgentProvider: api.agentProvider,
AppSecurityKey: options.AppSecurityKey,
DisablePathApps: options.DeploymentValues.DisablePathApps.Value(),
@ -921,10 +936,10 @@ type API struct {
derpCloseFunc func()
metricsCache *metricscache.Cache
workspaceAgentCache *wsconncache.Cache
updateChecker *updatecheck.Checker
WorkspaceAppsProvider workspaceapps.SignedTokenProvider
workspaceAppServer *workspaceapps.Server
agentProvider workspaceapps.AgentProvider
// Experiments contains the list of experiments currently enabled.
// This is used to gate features that are not yet ready for production.
@ -951,7 +966,8 @@ func (api *API) Close() error {
if coordinator != nil {
_ = (*coordinator).Close()
}
return api.workspaceAgentCache.Close()
_ = api.agentProvider.Close()
return nil
}
func compressHandler(h http.Handler) http.Handler {