Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1af6b7c

Browse files
committed
chore: add experiment toggle for terraform workspace caching
1 parent68b21e2 commit1af6b7c

File tree

6 files changed

+36
-12
lines changed

6 files changed

+36
-12
lines changed

‎cli/server.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,7 @@ func newProvisionerDaemon(
14761476
Listener:terraformServer,
14771477
Logger:provisionerLogger,
14781478
WorkDirectory:workDir,
1479+
Experiments:coderAPI.Experiments,
14791480
},
14801481
CachePath:tfDir,
14811482
Tracer:tracer,

‎codersdk/deployment.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,6 +3635,8 @@ const (
36353635
ExperimentOAuth2Experiment="oauth2"// Enables OAuth2 provider functionality.
36363636
ExperimentMCPServerHTTPExperiment="mcp-server-http"// Enables the MCP HTTP server functionality.
36373637
ExperimentWorkspaceSharingExperiment="workspace-sharing"// Enables updating workspace ACLs for sharing with users and groups.
3638+
// ExperimentTerraformWorkspace is named after the "Terraform Workspaces" feature, not to be confused with Coder Workspaces.
3639+
ExperimentTerraformWorkspaceExperiment="terraform-workspaces"// Enables reuse of existing terraform directory for builds
36383640
)
36393641

36403642
func (eExperiment)DisplayName()string {
@@ -3655,6 +3657,8 @@ func (e Experiment) DisplayName() string {
36553657
return"MCP HTTP Server Functionality"
36563658
caseExperimentWorkspaceSharing:
36573659
return"Workspace Sharing"
3660+
caseExperimentTerraformWorkspace:
3661+
return"Terraform Workspace Caching"
36583662
default:
36593663
// Split on hyphen and convert to title case
36603664
// e.g. "web-push" -> "Web Push", "mcp-server-http" -> "Mcp Server Http"

‎enterprise/cli/provisionerdaemonstart.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/coder/coder/v2/cli/clilog"
2424
"github.com/coder/coder/v2/cli/cliui"
2525
"github.com/coder/coder/v2/cli/cliutil"
26+
"github.com/coder/coder/v2/coderd"
2627
"github.com/coder/coder/v2/coderd/database"
2728
"github.com/coder/coder/v2/codersdk"
2829
"github.com/coder/coder/v2/codersdk/drpcsdk"
@@ -48,6 +49,7 @@ func (r *RootCmd) provisionerDaemonStart() *serpent.Command {
4849
preSharedKeystring
4950
provisionerKeystring
5051
verbosebool
52+
experiments []string
5153

5254
prometheusEnablebool
5355
prometheusAddressstring
@@ -186,6 +188,7 @@ func (r *RootCmd) provisionerDaemonStart() *serpent.Command {
186188
Listener:terraformServer,
187189
Logger:logger.Named("terraform"),
188190
WorkDirectory:tempDir,
191+
Experiments:coderd.ReadExperiments(logger,experiments),
189192
},
190193
CachePath:cacheDir,
191194
})
@@ -378,6 +381,14 @@ func (r *RootCmd) provisionerDaemonStart() *serpent.Command {
378381
Value:serpent.StringOf(&prometheusAddress),
379382
Default:"127.0.0.1:2112",
380383
},
384+
{
385+
Name:"Experiments",
386+
Description:"Enable one or more experiments. These are not ready for production. Separate multiple experiments with commas, or enter '*' to opt-in to all available experiments.",
387+
Flag:"experiments",
388+
Env:"CODER_EXPERIMENTS",
389+
Value:serpent.StringArrayOf(&experiments),
390+
YAML:"experiments",
391+
},
381392
}
382393
orgContext.AttachOptions(cmd)
383394

‎enterprise/coderd/coderdenttest/coderdenttest.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ func newExternalProvisionerDaemon(t testing.TB, client *codersdk.Client, org uui
414414
ServeOptions:&provisionersdk.ServeOptions{
415415
Listener:provisionerSrv,
416416
WorkDirectory:t.TempDir(),
417+
Experiments: codersdk.Experiments{},
417418
},
418419
}))
419420
}()

‎provisionersdk/serve.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"storj.io/drpc/drpcserver"
1616

1717
"cdr.dev/slog"
18+
"github.com/coder/coder/v2/codersdk"
1819
"github.com/coder/coder/v2/codersdk/drpcsdk"
1920

2021
"github.com/coder/coder/v2/coderd/tracing"
@@ -30,6 +31,7 @@ type ServeOptions struct {
3031
Logger slog.Logger
3132
WorkDirectorystring
3233
ExternalProvisionerbool
34+
Experiments codersdk.Experiments
3335
}
3436

3537
typeServerinterface {

‎provisionersdk/session.go‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ func (p *protoServer) Session(stream proto.DRPCProvisioner_SessionStream) error
5151
returnxerrors.Errorf("unable to clean stale sessions %q: %w",s.WorkDirectory,err)
5252
}
5353

54+
req,err:=stream.Recv()
55+
iferr!=nil {
56+
returnxerrors.Errorf("receive config: %w",err)
57+
}
58+
config:=req.GetConfig()
59+
ifconfig==nil {
60+
returnxerrors.New("first request must be Config")
61+
}
62+
s.Config=config
63+
ifs.Config.ProvisionerLogLevel!="" {
64+
s.logLevel=proto.LogLevel_value[strings.ToUpper(s.Config.ProvisionerLogLevel)]
65+
}
66+
67+
// Provision working directory for terraform execution.
5468
s.WorkDirectory=filepath.Join(p.opts.WorkDirectory,SessionDir(sessID))
5569
err=os.MkdirAll(s.WorkDirectory,0o700)
5670
iferr!=nil {
@@ -76,23 +90,14 @@ func (p *protoServer) Session(stream proto.DRPCProvisioner_SessionStream) error
7690
s.Logger.Error(s.Context(),"failed to clean up work directory after multiple attempts",
7791
slog.F("path",s.WorkDirectory),slog.Error(err))
7892
}()
79-
req,err:=stream.Recv()
80-
iferr!=nil {
81-
returnxerrors.Errorf("receive config: %w",err)
82-
}
83-
config:=req.GetConfig()
84-
ifconfig==nil {
85-
returnxerrors.New("first request must be Config")
86-
}
87-
s.Config=config
88-
ifs.Config.ProvisionerLogLevel!="" {
89-
s.logLevel=proto.LogLevel_value[strings.ToUpper(s.Config.ProvisionerLogLevel)]
90-
}
9193

94+
// Extract the template source archive into the work directory.
9295
err=s.extractArchive()
9396
iferr!=nil {
9497
returnxerrors.Errorf("extract archive: %w",err)
9598
}
99+
100+
// Handle requests, which will amount to terraform cli execs.
96101
returns.handleRequests()
97102
}
98103

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp