mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: add experiment toggle for terraform workspace caching (#20559)
Experiments passed to provisioners to determine behavior. This adds `--experiments` flag to provisioner daemons. Prior to this, provisioners had no method to turn on/off experiments.
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/coder/coder/v2/cli/clilog"
|
||||
"github.com/coder/coder/v2/cli/cliui"
|
||||
"github.com/coder/coder/v2/cli/cliutil"
|
||||
"github.com/coder/coder/v2/coderd"
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
"github.com/coder/coder/v2/codersdk/drpcsdk"
|
||||
@@ -48,6 +49,7 @@ func (r *RootCmd) provisionerDaemonStart() *serpent.Command {
|
||||
preSharedKey string
|
||||
provisionerKey string
|
||||
verbose bool
|
||||
experiments []string
|
||||
|
||||
prometheusEnable bool
|
||||
prometheusAddress string
|
||||
@@ -186,6 +188,7 @@ func (r *RootCmd) provisionerDaemonStart() *serpent.Command {
|
||||
Listener: terraformServer,
|
||||
Logger: logger.Named("terraform"),
|
||||
WorkDirectory: tempDir,
|
||||
Experiments: coderd.ReadExperiments(logger, experiments),
|
||||
},
|
||||
CachePath: cacheDir,
|
||||
})
|
||||
@@ -378,6 +381,14 @@ func (r *RootCmd) provisionerDaemonStart() *serpent.Command {
|
||||
Value: serpent.StringOf(&prometheusAddress),
|
||||
Default: "127.0.0.1:2112",
|
||||
},
|
||||
{
|
||||
Name: "Experiments",
|
||||
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.",
|
||||
Flag: "experiments",
|
||||
Env: "CODER_EXPERIMENTS",
|
||||
Value: serpent.StringArrayOf(&experiments),
|
||||
YAML: "experiments",
|
||||
},
|
||||
}
|
||||
orgContext.AttachOptions(cmd)
|
||||
|
||||
|
||||
@@ -6,6 +6,11 @@ USAGE:
|
||||
Run a provisioner daemon
|
||||
|
||||
OPTIONS:
|
||||
--experiments string-array, $CODER_EXPERIMENTS
|
||||
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.
|
||||
|
||||
-O, --org string, $CODER_ORGANIZATION
|
||||
Select which organization (uuid or name) to use.
|
||||
|
||||
|
||||
@@ -414,6 +414,7 @@ func newExternalProvisionerDaemon(t testing.TB, client *codersdk.Client, org uui
|
||||
ServeOptions: &provisionersdk.ServeOptions{
|
||||
Listener: provisionerSrv,
|
||||
WorkDirectory: t.TempDir(),
|
||||
Experiments: codersdk.Experiments{},
|
||||
},
|
||||
}))
|
||||
}()
|
||||
|
||||
@@ -362,6 +362,7 @@ func (api *API) provisionerDaemonServe(rw http.ResponseWriter, r *http.Request)
|
||||
api.NotificationsEnqueuer,
|
||||
&api.AGPL.PrebuildsReconciler,
|
||||
api.ProvisionerdServerMetrics,
|
||||
api.AGPL.Experiments,
|
||||
)
|
||||
if err != nil {
|
||||
if !xerrors.Is(err, context.Canceled) {
|
||||
|
||||
Reference in New Issue
Block a user