Skip to content

Commit 1372bf8

Browse files
authored
chore: revert "chore: remove workspace_actions experiment (coder#10030)" (coder#10363)
1 parent 57c9d88 commit 1372bf8

20 files changed

+124
-36
lines changed

cli/templatecreate.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ func (r *RootCmd) templateCreate() *clibase.Cmd {
5050
isTemplateSchedulingOptionsSet := failureTTL != 0 || inactivityTTL != 0 || maxTTL != 0
5151

5252
if isTemplateSchedulingOptionsSet || requireActiveVersion {
53+
if failureTTL != 0 || inactivityTTL != 0 {
54+
// This call can be removed when workspace_actions is no longer experimental
55+
experiments, exErr := client.Experiments(inv.Context())
56+
if exErr != nil {
57+
return xerrors.Errorf("get experiments: %w", exErr)
58+
}
59+
60+
if !experiments.Enabled(codersdk.ExperimentWorkspaceActions) {
61+
return xerrors.Errorf("--failure-ttl and --inactivity-ttl are experimental features. Use the workspace_actions CODER_EXPERIMENTS flag to set these configuration values.")
62+
}
63+
}
64+
5365
entitlements, err := client.Entitlements(inv.Context())
5466
if cerr, ok := codersdk.AsError(err); ok && cerr.StatusCode() == http.StatusNotFound {
5567
return xerrors.Errorf("your deployment appears to be an AGPL deployment, so you cannot set enterprise-only flags")
@@ -59,7 +71,7 @@ func (r *RootCmd) templateCreate() *clibase.Cmd {
5971

6072
if isTemplateSchedulingOptionsSet {
6173
if !entitlements.Features[codersdk.FeatureAdvancedTemplateScheduling].Enabled {
62-
return xerrors.Errorf("your license is not entitled to use advanced template scheduling, so you cannot set --failure-ttl or --inactivityTTL")
74+
return xerrors.Errorf("your license is not entitled to use advanced template scheduling, so you cannot set --failure-ttl, --inactivity-ttl, or --max-ttl")
6375
}
6476
}
6577

cli/templateedit.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ func (r *RootCmd) templateEdit() *clibase.Cmd {
4343
),
4444
Short: "Edit the metadata of a template by name.",
4545
Handler: func(inv *clibase.Invocation) error {
46+
// This clause can be removed when workspace_actions is no longer experimental
47+
if failureTTL != 0 || inactivityTTL != 0 {
48+
experiments, exErr := client.Experiments(inv.Context())
49+
if exErr != nil {
50+
return xerrors.Errorf("get experiments: %w", exErr)
51+
}
52+
53+
if !experiments.Enabled(codersdk.ExperimentWorkspaceActions) {
54+
return xerrors.Errorf("--failure-ttl and --inactivity-ttl are experimental features. Use the workspace_actions CODER_EXPERIMENTS flag to set these configuration values.")
55+
}
56+
}
57+
4658
unsetAutostopRequirementDaysOfWeek := len(autostopRequirementDaysOfWeek) == 1 && autostopRequirementDaysOfWeek[0] == "none"
4759
requiresScheduling := (len(autostopRequirementDaysOfWeek) > 0 && !unsetAutostopRequirementDaysOfWeek) ||
4860
autostopRequirementWeeks > 0 ||

coderd/apidoc/docs.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codersdk/deployment.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,9 @@ const (
19731973
// feature is not yet complete in functionality.
19741974
ExperimentMoons Experiment = "moons"
19751975

1976+
// https://github.com/coder/coder/milestone/19
1977+
ExperimentWorkspaceActions Experiment = "workspace_actions"
1978+
19761979
// ExperimentTailnetPGCoordinator enables the PGCoord in favor of the pubsub-
19771980
// only Coordinator
19781981
ExperimentTailnetPGCoordinator Experiment = "tailnet_pg_coordinator"

docs/api/schemas.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/api/typesGenerated.ts

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/components/Dashboard/DashboardProvider.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,13 @@ export const useDashboard = (): DashboardProviderValue => {
112112

113113
return context;
114114
};
115+
116+
export const useIsWorkspaceActionsEnabled = (): boolean => {
117+
const { entitlements, experiments } = useDashboard();
118+
const allowAdvancedScheduling =
119+
entitlements.features["advanced_template_scheduling"].enabled;
120+
// This check can be removed when https://github.com/coder/coder/milestone/19
121+
// is merged up
122+
const allowWorkspaceActions = experiments.includes("workspace_actions");
123+
return allowWorkspaceActions && allowAdvancedScheduling;
124+
};

site/src/components/WorkspaceDeletion/DormantDeletionStat.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,20 @@ interface DormantDeletionStatProps {
1414
export const DormantDeletionStat: FC<DormantDeletionStatProps> = ({
1515
workspace,
1616
}) => {
17-
const { entitlements } = useDashboard();
17+
const { entitlements, experiments } = useDashboard();
1818
const allowAdvancedScheduling =
1919
entitlements.features["advanced_template_scheduling"].enabled;
20+
// This check can be removed when https://github.com/coder/coder/milestone/19
21+
// is merged up
22+
const allowWorkspaceActions = experiments.includes("workspace_actions");
2023

21-
if (!displayDormantDeletion(workspace, allowAdvancedScheduling)) {
24+
if (
25+
!displayDormantDeletion(
26+
workspace,
27+
allowAdvancedScheduling,
28+
allowWorkspaceActions,
29+
)
30+
) {
2231
return null;
2332
}
2433

site/src/components/WorkspaceDeletion/DormantDeletionText.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@ export const DormantDeletionText = ({
99
}: {
1010
workspace: Workspace;
1111
}): JSX.Element | null => {
12-
const { entitlements } = useDashboard();
12+
const { entitlements, experiments } = useDashboard();
1313
const allowAdvancedScheduling =
1414
entitlements.features["advanced_template_scheduling"].enabled;
15+
// This check can be removed when https://github.com/coder/coder/milestone/19
16+
// is merged up
17+
const allowWorkspaceActions = experiments.includes("workspace_actions");
1518

16-
if (!displayDormantDeletion(workspace, allowAdvancedScheduling)) {
19+
if (
20+
!displayDormantDeletion(
21+
workspace,
22+
allowAdvancedScheduling,
23+
allowWorkspaceActions,
24+
)
25+
) {
1726
return null;
1827
}
1928
return <StyledSpan role="status">Impending deletion</StyledSpan>;

0 commit comments

Comments
 (0)