Skip to content

chore: remove workspace_actions experiment #10030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions cli/templatecreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ func (r *RootCmd) templateCreate() *clibase.Cmd {
),
Handler: func(inv *clibase.Invocation) error {
if failureTTL != 0 || inactivityTTL != 0 || maxTTL != 0 {
// This call can be removed when workspace_actions is no longer experimental
experiments, exErr := client.Experiments(inv.Context())
if exErr != nil {
return xerrors.Errorf("get experiments: %w", exErr)
}

if !experiments.Enabled(codersdk.ExperimentWorkspaceActions) {
return xerrors.Errorf("--failure-ttl and --inactivityTTL are experimental features. Use the workspace_actions CODER_EXPERIMENTS flag to set these configuration values.")
}

entitlements, err := client.Entitlements(inv.Context())
var sdkErr *codersdk.Error
if xerrors.As(err, &sdkErr) && sdkErr.StatusCode() == http.StatusNotFound {
Expand Down
12 changes: 0 additions & 12 deletions cli/templateedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@ func (r *RootCmd) templateEdit() *clibase.Cmd {
),
Short: "Edit the metadata of a template by name.",
Handler: func(inv *clibase.Invocation) error {
// This clause can be removed when workspace_actions is no longer experimental
if failureTTL != 0 || inactivityTTL != 0 {
experiments, exErr := client.Experiments(inv.Context())
if exErr != nil {
return xerrors.Errorf("get experiments: %w", exErr)
}

if !experiments.Enabled(codersdk.ExperimentWorkspaceActions) {
return xerrors.Errorf("--failure-ttl and --inactivityTTL are experimental features. Use the workspace_actions CODER_EXPERIMENTS flag to set these configuration values.")
}
}

unsetAutostopRequirementDaysOfWeek := len(autostopRequirementDaysOfWeek) == 1 && autostopRequirementDaysOfWeek[0] == "none"
requiresEntitlement := (len(autostopRequirementDaysOfWeek) > 0 && !unsetAutostopRequirementDaysOfWeek) ||
autostopRequirementWeeks > 0 ||
Expand Down
2 changes: 0 additions & 2 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1958,9 +1958,6 @@ const (
// feature is not yet complete in functionality.
ExperimentMoons Experiment = "moons"

// https://github.com/coder/coder/milestone/19
ExperimentWorkspaceActions Experiment = "workspace_actions"

// ExperimentTailnetPGCoordinator enables the PGCoord in favor of the pubsub-
// only Coordinator
ExperimentTailnetPGCoordinator Experiment = "tailnet_pg_coordinator"
Expand Down
1 change: 0 additions & 1 deletion docs/api/schemas.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions site/src/api/typesGenerated.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions site/src/components/Dashboard/DashboardProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,3 @@ export const useDashboard = (): DashboardProviderValue => {

return context;
};

export const useIsWorkspaceActionsEnabled = (): boolean => {
const { entitlements, experiments } = useDashboard();
const allowAdvancedScheduling =
entitlements.features["advanced_template_scheduling"].enabled;
// This check can be removed when https://github.com/coder/coder/milestone/19
// is merged up
const allowWorkspaceActions = experiments.includes("workspace_actions");
return allowWorkspaceActions && allowAdvancedScheduling;
};
13 changes: 2 additions & 11 deletions site/src/components/WorkspaceDeletion/DormantDeletionStat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,11 @@ interface DormantDeletionStatProps {
export const DormantDeletionStat: FC<DormantDeletionStatProps> = ({
workspace,
}) => {
const { entitlements, experiments } = useDashboard();
const { entitlements } = useDashboard();
const allowAdvancedScheduling =
entitlements.features["advanced_template_scheduling"].enabled;
// This check can be removed when https://github.com/coder/coder/milestone/19
// is merged up
const allowWorkspaceActions = experiments.includes("workspace_actions");

if (
!displayDormantDeletion(
workspace,
allowAdvancedScheduling,
allowWorkspaceActions,
)
) {
if (!displayDormantDeletion(workspace, allowAdvancedScheduling)) {
return null;
}

Expand Down
13 changes: 2 additions & 11 deletions site/src/components/WorkspaceDeletion/DormantDeletionText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@ export const DormantDeletionText = ({
}: {
workspace: Workspace;
}): JSX.Element | null => {
const { entitlements, experiments } = useDashboard();
const { entitlements } = useDashboard();
const allowAdvancedScheduling =
entitlements.features["advanced_template_scheduling"].enabled;
// This check can be removed when https://github.com/coder/coder/milestone/19
// is merged up
const allowWorkspaceActions = experiments.includes("workspace_actions");

if (
!displayDormantDeletion(
workspace,
allowAdvancedScheduling,
allowWorkspaceActions,
)
) {
if (!displayDormantDeletion(workspace, allowAdvancedScheduling)) {
return null;
}
return <StyledSpan role="status">Impending deletion</StyledSpan>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Workspace } from "api/typesGenerated";
import { useIsWorkspaceActionsEnabled } from "components/Dashboard/DashboardProvider";
import { useDashboard } from "components/Dashboard/DashboardProvider";
import { Alert } from "components/Alert/Alert";
import { formatDistanceToNow } from "date-fns";
import Link from "@mui/material/Link";
Expand All @@ -21,7 +21,9 @@ export const DormantWorkspaceBanner = ({
shouldRedisplayBanner: boolean;
count?: Count;
}): JSX.Element | null => {
const experimentEnabled = useIsWorkspaceActionsEnabled();
const { entitlements } = useDashboard();
const schedulingEnabled =
entitlements.features["advanced_template_scheduling"].enabled;

if (!workspaces) {
return null;
Expand All @@ -37,7 +39,7 @@ export const DormantWorkspaceBanner = ({

if (
// Only show this if the experiment is included.
!experimentEnabled ||
!schedulingEnabled ||
!hasDormantWorkspaces ||
// Banners should be redisplayed after dismissal when additional workspaces are newly scheduled for deletion
!shouldRedisplayBanner
Expand Down
30 changes: 8 additions & 22 deletions site/src/components/WorkspaceDeletion/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,39 @@ import { displayDormantDeletion } from "./utils";

describe("displayDormantDeletion", () => {
const today = new Date();
it.each<[string, boolean, boolean, boolean]>([
it.each<[string, boolean, boolean]>([
[
new Date(new Date().setDate(today.getDate() + 15)).toISOString(),
true,
true,
false,
], // today + 15 days out
[
new Date(new Date().setDate(today.getDate() + 14)).toISOString(),
true,
true,
true,
], // today + 14
[
new Date(new Date().setDate(today.getDate() + 13)).toISOString(),
true,
true,
true,
], // today + 13
[
new Date(new Date().setDate(today.getDate() + 1)).toISOString(),
true,
true,
true,
], // today + 1
[new Date().toISOString(), true, true, true], // today + 0
[new Date().toISOString(), false, true, false], // Advanced Scheduling off
[new Date().toISOString(), true, false, false], // Workspace Actions off
[new Date().toISOString(), true, true], // today + 0
[new Date().toISOString(), false, false], // Advanced Scheduling off
])(
`deleting_at=%p, allowAdvancedScheduling=%p, AllowWorkspaceActions=%p, shouldDisplay=%p`,
(
deleting_at,
allowAdvancedScheduling,
allowWorkspaceActions,
shouldDisplay,
) => {
`deleting_at=%p, allowAdvancedScheduling=%p, shouldDisplay=%p`,
(deleting_at, allowAdvancedScheduling, shouldDisplay) => {
const workspace: TypesGen.Workspace = {
...Mocks.MockWorkspace,
deleting_at,
};
expect(
displayDormantDeletion(
workspace,
allowAdvancedScheduling,
allowWorkspaceActions,
),
).toBe(shouldDisplay);
expect(displayDormantDeletion(workspace, allowAdvancedScheduling)).toBe(
shouldDisplay,
);
},
);
});
7 changes: 1 addition & 6 deletions site/src/components/WorkspaceDeletion/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ const IMPENDING_DELETION_DISPLAY_THRESHOLD = 14; // 14 days
export const displayDormantDeletion = (
workspace: Workspace,
allowAdvancedScheduling: boolean,
allowWorkspaceActions: boolean,
) => {
const today = new Date();
if (
!workspace.deleting_at ||
!allowAdvancedScheduling ||
!allowWorkspaceActions
) {
if (!workspace.deleting_at || !allowAdvancedScheduling) {
return false;
}
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ const meta: Meta<typeof GeneralSettingsPageView> = {
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",
value: [
"*",
"moons",
"workspace_actions",
"single_tailnet",
"deployment_health_page",
],
value: ["*", "moons", "single_tailnet", "deployment_health_page"],
flag_shorthand: "",
hidden: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export interface TemplateScheduleForm {
isSubmitting: boolean;
error?: unknown;
allowAdvancedScheduling: boolean;
allowWorkspaceActions: boolean;
allowAutostopRequirement: boolean;
// Helpful to show field errors on Storybook
initialTouched?: FormikTouched<UpdateTemplateMeta>;
Expand All @@ -62,7 +61,6 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
onCancel,
error,
allowAdvancedScheduling,
allowWorkspaceActions,
allowAutostopRequirement,
isSubmitting,
initialTouched,
Expand Down Expand Up @@ -459,7 +457,7 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
</Stack>
</Stack>
</FormSection>
{allowAdvancedScheduling && allowWorkspaceActions && (
{allowAdvancedScheduling && (
<>
<FormSection
title="Failure Cleanup"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ describe("TemplateSchedulePage", () => {
jest
.spyOn(API, "getEntitlements")
.mockResolvedValue(MockEntitlementsWithScheduling);

// remove when https://github.com/coder/coder/milestone/19 is completed.
jest.spyOn(API, "getExperiments").mockResolvedValue(["workspace_actions"]);
});

it("Calls the API when user fills in and submits a form", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ const TemplateSchedulePage: FC = () => {
const queryClient = useQueryClient();
const orgId = useOrganizationId();
const { template } = useTemplateSettings();
const { entitlements, experiments } = useDashboard();
const { entitlements } = useDashboard();
const allowAdvancedScheduling =
entitlements.features["advanced_template_scheduling"].enabled;
// This check can be removed when https://github.com/coder/coder/milestone/19
// is merged up
const allowWorkspaceActions = experiments.includes("workspace_actions");
const allowAutostopRequirement =
entitlements.features["template_autostop_requirement"].enabled;
const { clearLocal } = useLocalStorage();
Expand Down Expand Up @@ -54,7 +53,6 @@ const TemplateSchedulePage: FC = () => {
</Helmet>
<TemplateSchedulePageView
allowAdvancedScheduling={allowAdvancedScheduling}
allowWorkspaceActions={allowWorkspaceActions}
allowAutostopRequirement={allowAutostopRequirement}
isSubmitting={isSubmitting}
template={template}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Story = StoryObj<typeof TemplateSchedulePageView>;

const defaultArgs = {
allowAdvancedScheduling: true,
allowWorkspaceActions: true,
template: MockTemplate,
onSubmit: action("onSubmit"),
onCancel: action("cancel"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export interface TemplateSchedulePageViewProps {
typeof TemplateScheduleForm
>["initialTouched"];
allowAdvancedScheduling: boolean;
allowWorkspaceActions: boolean;
allowAutostopRequirement: boolean;
}

Expand All @@ -24,7 +23,6 @@ export const TemplateSchedulePageView: FC<TemplateSchedulePageViewProps> = ({
onSubmit,
isSubmitting,
allowAdvancedScheduling,
allowWorkspaceActions,
allowAutostopRequirement,
submitError,
initialTouched,
Expand All @@ -39,7 +37,6 @@ export const TemplateSchedulePageView: FC<TemplateSchedulePageViewProps> = ({

<TemplateScheduleForm
allowAdvancedScheduling={allowAdvancedScheduling}
allowWorkspaceActions={allowWorkspaceActions}
allowAutostopRequirement={allowAutostopRequirement}
initialTouched={initialTouched}
isSubmitting={isSubmitting}
Expand Down
Loading