Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add feature flag
  • Loading branch information
coadler committed Jul 11, 2023
commit 7bfac9be2bafccadadb58439816c5174e10de103
6 changes: 4 additions & 2 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 18 additions & 12 deletions coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,21 @@ func New(options *Options) *API {

api.Auditor.Store(&options.Auditor)
api.TailnetCoordinator.Store(&options.TailnetCoordinator)
api.tailnet, 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())
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{
Expand All @@ -385,7 +391,7 @@ func New(options *Options) *API {
RealIPConfig: options.RealIPConfig,

SignedTokenProvider: api.WorkspaceAppsProvider,
AgentProvider: api.tailnet,
AgentProvider: api.agentProvider,
AppSecurityKey: options.AppSecurityKey,

DisablePathApps: options.DeploymentValues.DisablePathApps.Value(),
Expand Down Expand Up @@ -923,7 +929,7 @@ type API struct {
updateChecker *updatecheck.Checker
WorkspaceAppsProvider workspaceapps.SignedTokenProvider
workspaceAppServer *workspaceapps.Server
tailnet *ServerTailnet
agentProvider workspaceapps.AgentProvider

// Experiments contains the list of experiments currently enabled.
// This is used to gate features that are not yet ready for production.
Expand All @@ -950,7 +956,7 @@ func (api *API) Close() error {
if coordinator != nil {
_ = (*coordinator).Close()
}
_ = api.tailnet.Close()
_ = api.agentProvider.Close()
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion coderd/workspaceagents.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ func (api *API) workspaceAgentListeningPorts(rw http.ResponseWriter, r *http.Req
return
}

agentConn, release, err := api.tailnet.AgentConn(ctx, workspaceAgent.ID)
agentConn, release, err := api.agentProvider.AgentConn(ctx, workspaceAgent.ID)
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error dialing workspace agent.",
Expand Down
6 changes: 6 additions & 0 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,12 @@ const (
// oidc.
ExperimentConvertToOIDC Experiment = "convert-to-oidc"

// ExperimentSingleTailnet replaces workspace connections inside coderd to
// all use a single tailnet, instead of the previous behavior of creating a
// single tailnet for each agent.
// WARNING: This cannot be enabled when using HA.
ExperimentSingleTailnet Experiment = "single_tailnet"

// Add new experiments here!
// ExperimentExample Experiment = "example"
)
Expand Down
1 change: 1 addition & 0 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -2539,6 +2539,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in
| `workspace_actions` |
| `tailnet_pg_coordinator` |
| `convert-to-oidc` |
| `single_tailnet` |

## codersdk.Feature

Expand Down
2 changes: 2 additions & 0 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1414,11 +1414,13 @@ export const Entitlements: Entitlement[] = [
export type Experiment =
| "convert-to-oidc"
| "moons"
| "single_tailnet"
| "tailnet_pg_coordinator"
| "workspace_actions"
export const Experiments: Experiment[] = [
"convert-to-oidc",
"moons",
"single_tailnet",
"tailnet_pg_coordinator",
"workspace_actions",
]
Expand Down