mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: allow templates to specify max_ttl or autostop_requirement (#10920)
This commit is contained in:
+17
-34
@@ -35,22 +35,21 @@ const (
|
||||
type FeatureName string
|
||||
|
||||
const (
|
||||
FeatureUserLimit FeatureName = "user_limit"
|
||||
FeatureAuditLog FeatureName = "audit_log"
|
||||
FeatureBrowserOnly FeatureName = "browser_only"
|
||||
FeatureSCIM FeatureName = "scim"
|
||||
FeatureTemplateRBAC FeatureName = "template_rbac"
|
||||
FeatureUserRoleManagement FeatureName = "user_role_management"
|
||||
FeatureHighAvailability FeatureName = "high_availability"
|
||||
FeatureMultipleExternalAuth FeatureName = "multiple_external_auth"
|
||||
FeatureExternalProvisionerDaemons FeatureName = "external_provisioner_daemons"
|
||||
FeatureAppearance FeatureName = "appearance"
|
||||
FeatureAdvancedTemplateScheduling FeatureName = "advanced_template_scheduling"
|
||||
FeatureWorkspaceProxy FeatureName = "workspace_proxy"
|
||||
FeatureExternalTokenEncryption FeatureName = "external_token_encryption"
|
||||
FeatureTemplateAutostopRequirement FeatureName = "template_autostop_requirement"
|
||||
FeatureWorkspaceBatchActions FeatureName = "workspace_batch_actions"
|
||||
FeatureAccessControl FeatureName = "access_control"
|
||||
FeatureUserLimit FeatureName = "user_limit"
|
||||
FeatureAuditLog FeatureName = "audit_log"
|
||||
FeatureBrowserOnly FeatureName = "browser_only"
|
||||
FeatureSCIM FeatureName = "scim"
|
||||
FeatureTemplateRBAC FeatureName = "template_rbac"
|
||||
FeatureUserRoleManagement FeatureName = "user_role_management"
|
||||
FeatureHighAvailability FeatureName = "high_availability"
|
||||
FeatureMultipleExternalAuth FeatureName = "multiple_external_auth"
|
||||
FeatureExternalProvisionerDaemons FeatureName = "external_provisioner_daemons"
|
||||
FeatureAppearance FeatureName = "appearance"
|
||||
FeatureAdvancedTemplateScheduling FeatureName = "advanced_template_scheduling"
|
||||
FeatureWorkspaceProxy FeatureName = "workspace_proxy"
|
||||
FeatureExternalTokenEncryption FeatureName = "external_token_encryption"
|
||||
FeatureWorkspaceBatchActions FeatureName = "workspace_batch_actions"
|
||||
FeatureAccessControl FeatureName = "access_control"
|
||||
)
|
||||
|
||||
// FeatureNames must be kept in-sync with the Feature enum above.
|
||||
@@ -65,11 +64,9 @@ var FeatureNames = []FeatureName{
|
||||
FeatureExternalProvisionerDaemons,
|
||||
FeatureAppearance,
|
||||
FeatureAdvancedTemplateScheduling,
|
||||
FeatureTemplateAutostopRequirement,
|
||||
FeatureWorkspaceProxy,
|
||||
FeatureUserRoleManagement,
|
||||
FeatureExternalTokenEncryption,
|
||||
FeatureTemplateAutostopRequirement,
|
||||
FeatureWorkspaceBatchActions,
|
||||
FeatureAccessControl,
|
||||
}
|
||||
@@ -1816,10 +1813,10 @@ Write out the current server config as YAML to stdout.`,
|
||||
},
|
||||
{
|
||||
Name: "Default Quiet Hours Schedule",
|
||||
Description: "The default daily cron schedule applied to users that haven't set a custom quiet hours schedule themselves. The quiet hours schedule determines when workspaces will be force stopped due to the template's max TTL, and will round the max TTL up to be within the user's quiet hours window (or default). The format is the same as the standard cron format, but the day-of-month, month and day-of-week must be *. Only one hour and minute can be specified (ranges or comma separated values are not supported).",
|
||||
Description: "The default daily cron schedule applied to users that haven't set a custom quiet hours schedule themselves. The quiet hours schedule determines when workspaces will be force stopped due to the template's autostop requirement, and will round the max deadline up to be within the user's quiet hours window (or default). The format is the same as the standard cron format, but the day-of-month, month and day-of-week must be *. Only one hour and minute can be specified (ranges or comma separated values are not supported).",
|
||||
Flag: "default-quiet-hours-schedule",
|
||||
Env: "CODER_QUIET_HOURS_DEFAULT_SCHEDULE",
|
||||
Default: "",
|
||||
Default: "CRON_TZ=UTC 0 0 * * *",
|
||||
Value: &c.UserQuietHoursSchedule.DefaultSchedule,
|
||||
Group: &deploymentGroupUserQuietHoursSchedule,
|
||||
YAML: "defaultQuietHoursSchedule",
|
||||
@@ -2071,20 +2068,6 @@ const (
|
||||
// single tailnet for each agent.
|
||||
ExperimentSingleTailnet Experiment = "single_tailnet"
|
||||
|
||||
// ExperimentTemplateAutostopRequirement allows template admins to have more
|
||||
// control over when workspaces created on a template are required to
|
||||
// stop, and allows users to ensure these restarts never happen during their
|
||||
// business hours.
|
||||
//
|
||||
// This will replace the MaxTTL setting on templates.
|
||||
//
|
||||
// Enables:
|
||||
// - User quiet hours schedule settings
|
||||
// - Template autostop requirement settings
|
||||
// - Changes the max_deadline algorithm to use autostop requirement and user
|
||||
// quiet hours instead of max_ttl.
|
||||
ExperimentTemplateAutostopRequirement Experiment = "template_autostop_requirement"
|
||||
|
||||
// Deployment health page
|
||||
ExperimentDeploymentHealthPage Experiment = "deployment_health_page"
|
||||
|
||||
|
||||
@@ -85,9 +85,11 @@ type CreateTemplateRequest struct {
|
||||
// for all workspaces created from this template.
|
||||
DefaultTTLMillis *int64 `json:"default_ttl_ms,omitempty"`
|
||||
// TODO(@dean): remove max_ttl once autostop_requirement is matured
|
||||
// Only one of MaxTTLMillis or AutostopRequirement can be specified.
|
||||
MaxTTLMillis *int64 `json:"max_ttl_ms,omitempty"`
|
||||
// AutostopRequirement allows optionally specifying the autostop requirement
|
||||
// for workspaces created from this template. This is an enterprise feature.
|
||||
// Only one of MaxTTLMillis or AutostopRequirement can be specified.
|
||||
AutostopRequirement *TemplateAutostopRequirement `json:"autostop_requirement,omitempty"`
|
||||
// AutostartRequirement allows optionally specifying the autostart allowed days
|
||||
// for workspaces created from this template. This is an enterprise feature.
|
||||
|
||||
@@ -31,6 +31,9 @@ type Template struct {
|
||||
DeprecationMessage string `json:"deprecation_message"`
|
||||
Icon string `json:"icon"`
|
||||
DefaultTTLMillis int64 `json:"default_ttl_ms"`
|
||||
// UseMaxTTL picks whether to use the deprecated max TTL for the template or
|
||||
// the new autostop requirement.
|
||||
UseMaxTTL bool `json:"use_max_ttl"`
|
||||
// TODO(@dean): remove max_ttl once autostop_requirement is matured
|
||||
MaxTTLMillis int64 `json:"max_ttl_ms"`
|
||||
// AutostopRequirement and AutostartRequirement are enterprise features. Its
|
||||
@@ -206,10 +209,12 @@ type UpdateTemplateMeta struct {
|
||||
Icon string `json:"icon,omitempty"`
|
||||
DefaultTTLMillis int64 `json:"default_ttl_ms,omitempty"`
|
||||
// TODO(@dean): remove max_ttl once autostop_requirement is matured
|
||||
// Only one of MaxTTLMillis or AutostopRequirement can be specified.
|
||||
MaxTTLMillis int64 `json:"max_ttl_ms,omitempty"`
|
||||
// AutostopRequirement and AutostartRequirement can only be set if your license
|
||||
// includes the advanced template scheduling feature. If you attempt to set this
|
||||
// value while unlicensed, it will be ignored.
|
||||
// Only one of MaxTTLMillis or AutostopRequirement can be specified.
|
||||
AutostopRequirement *TemplateAutostopRequirement `json:"autostop_requirement,omitempty"`
|
||||
AutostartRequirement *TemplateAutostartRequirement `json:"autostart_requirement,omitempty"`
|
||||
AllowUserAutostart bool `json:"allow_user_autostart,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user