mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: move moons experiment to ga (released) (#11285)
* feat: release moons experiment as ga
This commit is contained in:
+26
-27
@@ -362,34 +362,33 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
|
||||
}
|
||||
api.derpMesh = derpmesh.New(options.Logger.Named("derpmesh"), api.DERPServer, meshTLSConfig)
|
||||
|
||||
if api.AGPL.Experiments.Enabled(codersdk.ExperimentMoons) {
|
||||
// Proxy health is a moon feature.
|
||||
api.ProxyHealth, err = proxyhealth.New(&proxyhealth.Options{
|
||||
Interval: options.ProxyHealthInterval,
|
||||
DB: api.Database,
|
||||
Logger: options.Logger.Named("proxyhealth"),
|
||||
Client: api.HTTPClient,
|
||||
Prometheus: api.PrometheusRegistry,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("initialize proxy health: %w", err)
|
||||
}
|
||||
go api.ProxyHealth.Run(ctx)
|
||||
// Force the initial loading of the cache. Do this in a go routine in case
|
||||
// the calls to the workspace proxies hang and this takes some time.
|
||||
go api.forceWorkspaceProxyHealthUpdate(ctx)
|
||||
|
||||
// Use proxy health to return the healthy workspace proxy hostnames.
|
||||
f := api.ProxyHealth.ProxyHosts
|
||||
api.AGPL.WorkspaceProxyHostsFn.Store(&f)
|
||||
|
||||
// Wire this up to healthcheck.
|
||||
var fetchUpdater healthcheck.WorkspaceProxiesFetchUpdater = &workspaceProxiesFetchUpdater{
|
||||
fetchFunc: api.fetchWorkspaceProxies,
|
||||
updateFunc: api.ProxyHealth.ForceUpdate,
|
||||
}
|
||||
api.AGPL.WorkspaceProxiesFetchUpdater.Store(&fetchUpdater)
|
||||
// Moon feature init. Proxyhealh is a go routine to periodically check
|
||||
// the health of all workspace proxies.
|
||||
api.ProxyHealth, err = proxyhealth.New(&proxyhealth.Options{
|
||||
Interval: options.ProxyHealthInterval,
|
||||
DB: api.Database,
|
||||
Logger: options.Logger.Named("proxyhealth"),
|
||||
Client: api.HTTPClient,
|
||||
Prometheus: api.PrometheusRegistry,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("initialize proxy health: %w", err)
|
||||
}
|
||||
go api.ProxyHealth.Run(ctx)
|
||||
// Force the initial loading of the cache. Do this in a go routine in case
|
||||
// the calls to the workspace proxies hang and this takes some time.
|
||||
go api.forceWorkspaceProxyHealthUpdate(ctx)
|
||||
|
||||
// Use proxy health to return the healthy workspace proxy hostnames.
|
||||
f := api.ProxyHealth.ProxyHosts
|
||||
api.AGPL.WorkspaceProxyHostsFn.Store(&f)
|
||||
|
||||
// Wire this up to healthcheck.
|
||||
var fetchUpdater healthcheck.WorkspaceProxiesFetchUpdater = &workspaceProxiesFetchUpdater{
|
||||
fetchFunc: api.fetchWorkspaceProxies,
|
||||
updateFunc: api.ProxyHealth.ForceUpdate,
|
||||
}
|
||||
api.AGPL.WorkspaceProxiesFetchUpdater.Store(&fetchUpdater)
|
||||
|
||||
err = api.PrometheusRegistry.Register(&api.licenseMetricsCollector)
|
||||
if err != nil {
|
||||
|
||||
@@ -344,12 +344,6 @@ func (api *API) templateRBACEnabledMW(next http.Handler) http.Handler {
|
||||
|
||||
func (api *API) moonsEnabledMW(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
// The experiment must be enabled.
|
||||
if !api.AGPL.Experiments.Enabled(codersdk.ExperimentMoons) {
|
||||
httpapi.RouteNotFound(rw)
|
||||
return
|
||||
}
|
||||
|
||||
// Entitlement must be enabled.
|
||||
api.entitlementsMu.RLock()
|
||||
proxy := api.entitlements.Features[codersdk.FeatureWorkspaceProxy].Enabled
|
||||
|
||||
@@ -36,20 +36,13 @@ func TestRegions(t *testing.T) {
|
||||
t.Run("OK", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.Experiments = []string{
|
||||
string(codersdk.ExperimentMoons),
|
||||
"*",
|
||||
}
|
||||
|
||||
db, pubsub := dbtestutil.NewDB(t)
|
||||
|
||||
client, _ := coderdenttest.New(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
AppHostname: appHostname,
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
DeploymentValues: dv,
|
||||
AppHostname: appHostname,
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -79,20 +72,13 @@ func TestRegions(t *testing.T) {
|
||||
t.Run("WithProxies", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.Experiments = []string{
|
||||
string(codersdk.ExperimentMoons),
|
||||
"*",
|
||||
}
|
||||
|
||||
db, pubsub := dbtestutil.NewDB(t)
|
||||
|
||||
client, closer, api, _ := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
AppHostname: appHostname,
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
DeploymentValues: dv,
|
||||
AppHostname: appHostname,
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
},
|
||||
LicenseOptions: &coderdenttest.LicenseOptions{
|
||||
Features: license.Features{
|
||||
@@ -173,17 +159,10 @@ func TestRegions(t *testing.T) {
|
||||
t.Run("RequireAuth", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.Experiments = []string{
|
||||
string(codersdk.ExperimentMoons),
|
||||
"*",
|
||||
}
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
client, _ := coderdenttest.New(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
AppHostname: appHostname,
|
||||
DeploymentValues: dv,
|
||||
AppHostname: appHostname,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -200,15 +179,7 @@ func TestWorkspaceProxyCRUD(t *testing.T) {
|
||||
t.Run("CreateAndUpdate", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.Experiments = []string{
|
||||
string(codersdk.ExperimentMoons),
|
||||
"*",
|
||||
}
|
||||
client, _ := coderdenttest.New(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
DeploymentValues: dv,
|
||||
},
|
||||
LicenseOptions: &coderdenttest.LicenseOptions{
|
||||
Features: license.Features{
|
||||
codersdk.FeatureWorkspaceProxy: 1,
|
||||
@@ -251,15 +222,7 @@ func TestWorkspaceProxyCRUD(t *testing.T) {
|
||||
t.Run("Delete", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.Experiments = []string{
|
||||
string(codersdk.ExperimentMoons),
|
||||
"*",
|
||||
}
|
||||
client, _ := coderdenttest.New(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
DeploymentValues: dv,
|
||||
},
|
||||
LicenseOptions: &coderdenttest.LicenseOptions{
|
||||
Features: license.Features{
|
||||
codersdk.FeatureWorkspaceProxy: 1,
|
||||
@@ -287,16 +250,9 @@ func TestProxyRegisterDeregister(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
setup := func(t *testing.T) (*codersdk.Client, database.Store) {
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.Experiments = []string{
|
||||
string(codersdk.ExperimentMoons),
|
||||
"*",
|
||||
}
|
||||
|
||||
db, pubsub := dbtestutil.NewDB(t)
|
||||
client, _ := coderdenttest.New(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
DeploymentValues: dv,
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
IncludeProvisionerDaemon: true,
|
||||
@@ -635,16 +591,9 @@ func TestProxyRegisterDeregister(t *testing.T) {
|
||||
func TestIssueSignedAppToken(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.Experiments = []string{
|
||||
string(codersdk.ExperimentMoons),
|
||||
"*",
|
||||
}
|
||||
|
||||
db, pubsub := dbtestutil.NewDB(t)
|
||||
client, user := coderdenttest.New(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
DeploymentValues: dv,
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
IncludeProvisionerDaemon: true,
|
||||
@@ -732,16 +681,9 @@ func TestIssueSignedAppToken(t *testing.T) {
|
||||
func TestReconnectingPTYSignedToken(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.Experiments = []string{
|
||||
string(codersdk.ExperimentMoons),
|
||||
"*",
|
||||
}
|
||||
|
||||
db, pubsub := dbtestutil.NewDB(t)
|
||||
client, closer, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
DeploymentValues: dv,
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
IncludeProvisionerDaemon: true,
|
||||
|
||||
@@ -31,12 +31,6 @@ func Test_agentIsLegacy(t *testing.T) {
|
||||
t.Run("Legacy", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.Experiments = []string{
|
||||
string(codersdk.ExperimentMoons),
|
||||
"*",
|
||||
}
|
||||
|
||||
var (
|
||||
ctx, cancel = context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
db, pubsub = dbtestutil.NewDB(t)
|
||||
@@ -44,10 +38,9 @@ func Test_agentIsLegacy(t *testing.T) {
|
||||
coordinator = agpl.NewCoordinator(logger)
|
||||
client, _ = coderdenttest.New(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
DeploymentValues: dv,
|
||||
Coordinator: coordinator,
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
Coordinator: coordinator,
|
||||
},
|
||||
LicenseOptions: &coderdenttest.LicenseOptions{
|
||||
Features: license.Features{
|
||||
@@ -98,12 +91,6 @@ func Test_agentIsLegacy(t *testing.T) {
|
||||
t.Run("NotLegacy", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
dv.Experiments = []string{
|
||||
string(codersdk.ExperimentMoons),
|
||||
"*",
|
||||
}
|
||||
|
||||
var (
|
||||
ctx, cancel = context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
db, pubsub = dbtestutil.NewDB(t)
|
||||
@@ -111,10 +98,9 @@ func Test_agentIsLegacy(t *testing.T) {
|
||||
coordinator = agpl.NewCoordinator(logger)
|
||||
client, _ = coderdenttest.New(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
DeploymentValues: dv,
|
||||
Coordinator: coordinator,
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
Coordinator: coordinator,
|
||||
},
|
||||
LicenseOptions: &coderdenttest.LicenseOptions{
|
||||
Features: license.Features{
|
||||
|
||||
Reference in New Issue
Block a user