Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: remove workspace_actions experiment #11427

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 8 commits into from
Jan 10, 2024
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
12 changes: 0 additions & 12 deletions cli/templatecreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ func (r *RootCmd) templateCreate() *clibase.Cmd {
isTemplateSchedulingOptionsSet := failureTTL != 0 || dormancyThreshold != 0 || dormancyAutoDeletion != 0 || maxTTL != 0

if isTemplateSchedulingOptionsSet || requireActiveVersion {
if failureTTL != 0 || dormancyThreshold != 0 || dormancyAutoDeletion != 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, --dormancy-threshold, and --dormancy-auto-deletion are experimental features. Use the workspace_actions CODER_EXPERIMENTS flag to set these configuration values.")
}
}

entitlements, err := client.Entitlements(inv.Context())
if cerr, ok := codersdk.AsError(err); ok && cerr.StatusCode() == http.StatusNotFound {
return xerrors.Errorf("your deployment appears to be an AGPL deployment, so you cannot set enterprise-only flags")
Expand Down
12 changes: 0 additions & 12 deletions cli/templateedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,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 || dormancyThreshold != 0 || dormancyAutoDeletion != 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, --dormancy-threshold, and --dormancy-auto-deletion are experimental features. Use the workspace_actions CODER_EXPERIMENTS flag to set these configuration values.")
}
}

unsetAutostopRequirementDaysOfWeek := len(autostopRequirementDaysOfWeek) == 1 && autostopRequirementDaysOfWeek[0] == "none"
requiresScheduling := (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.

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

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

2 changes: 1 addition & 1 deletion coderd/database/models.go

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

2 changes: 1 addition & 1 deletion coderd/database/querier.go

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

2 changes: 1 addition & 1 deletion coderd/database/queries.sql.go

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 @@ -2077,9 +2077,6 @@ func (c *Client) BuildInfo(ctx context.Context) (BuildInfoResponse, error) {
type Experiment string

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

// Deployment health page
ExperimentDeploymentHealthPage Experiment = "deployment_health_page"

Expand Down
4 changes: 2 additions & 2 deletions docs/api/general.md

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

3 changes: 1 addition & 2 deletions docs/api/schemas.md

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

6 changes: 0 additions & 6 deletions enterprise/cli/templatecreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,13 @@ func TestTemplateCreate(t *testing.T) {
t.Run("WorkspaceCleanup", func(t *testing.T) {
t.Parallel()

dv := coderdtest.DeploymentValues(t)
dv.Experiments = []string{
string(codersdk.ExperimentWorkspaceActions),
}

client, user := coderdenttest.New(t, &coderdenttest.Options{
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureAdvancedTemplateScheduling: 1,
},
},
Options: &coderdtest.Options{
DeploymentValues: dv,
IncludeProvisionerDaemon: true,
},
})
Expand Down
6 changes: 0 additions & 6 deletions enterprise/cli/templateedit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,13 @@ func TestTemplateEdit(t *testing.T) {
t.Run("WorkspaceCleanup", func(t *testing.T) {
t.Parallel()

dv := coderdtest.DeploymentValues(t)
dv.Experiments = []string{
string(codersdk.ExperimentWorkspaceActions),
}

ownerClient, owner := coderdenttest.New(t, &coderdenttest.Options{
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureAdvancedTemplateScheduling: 1,
},
},
Options: &coderdtest.Options{
DeploymentValues: dv,
IncludeProvisionerDaemon: true,
},
})
Expand Down
7 changes: 2 additions & 5 deletions site/src/api/typesGenerated.ts

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

9 changes: 2 additions & 7 deletions site/src/components/Dashboard/DashboardProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ export const useDashboard = (): DashboardProviderValue => {
};

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;
const { entitlements } = useDashboard();
return entitlements.features["advanced_template_scheduling"].enabled;
};
11 changes: 2 additions & 9 deletions site/src/components/WorkspaceDeletion/DormantDeletionText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@ interface DormantDeletionTextProps {
export const DormantDeletionText: FC<DormantDeletionTextProps> = ({
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export interface TemplateScheduleForm {
isSubmitting: boolean;
error?: unknown;
allowAdvancedScheduling: boolean;
allowWorkspaceActions: boolean;
// Helpful to show field errors on Storybook
initialTouched?: FormikTouched<UpdateTemplateMeta>;
}
Expand All @@ -65,7 +64,6 @@ export const TemplateScheduleForm: FC<TemplateScheduleForm> = ({
onCancel,
error,
allowAdvancedScheduling,
allowWorkspaceActions,
isSubmitting,
initialTouched,
}) => {
Expand Down Expand Up @@ -562,7 +560,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 @@ -139,9 +139,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,9 @@ 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 { clearLocal } = useLocalStorage();

const {
Expand Down Expand Up @@ -52,7 +49,6 @@ const TemplateSchedulePage: FC = () => {
</Helmet>
<TemplateSchedulePageView
allowAdvancedScheduling={allowAdvancedScheduling}
allowWorkspaceActions={allowWorkspaceActions}
isSubmitting={isSubmitting}
template={template}
submitError={submitError}
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 @@ -13,7 +13,6 @@ export interface TemplateSchedulePageViewProps {
typeof TemplateScheduleForm
>["initialTouched"];
allowAdvancedScheduling: boolean;
allowWorkspaceActions: boolean;
}

export const TemplateSchedulePageView: FC<TemplateSchedulePageViewProps> = ({
Expand All @@ -22,7 +21,6 @@ export const TemplateSchedulePageView: FC<TemplateSchedulePageViewProps> = ({
onSubmit,
isSubmitting,
allowAdvancedScheduling,
allowWorkspaceActions,
submitError,
initialTouched,
}) => {
Expand All @@ -34,7 +32,6 @@ export const TemplateSchedulePageView: FC<TemplateSchedulePageViewProps> = ({

<TemplateScheduleForm
allowAdvancedScheduling={allowAdvancedScheduling}
allowWorkspaceActions={allowWorkspaceActions}
initialTouched={initialTouched}
isSubmitting={isSubmitting}
template={template}
Expand Down
1 change: 0 additions & 1 deletion site/src/pages/WorkspacePage/WorkspaceTopbar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const meta: Meta<typeof WorkspaceTopbar> = {
parameters: {
layout: "fullscreen",
features: ["advanced_template_scheduling"],
experiments: ["workspace_actions"],
},
};

Expand Down
4 changes: 1 addition & 3 deletions site/src/pages/WorkspacePage/WorkspaceTopbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,14 @@ export const WorkspaceTopbar = (props: WorkspaceProps) => {
});

// Dormant
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 shouldDisplayDormantData = displayDormantDeletion(
workspace,
allowAdvancedScheduling,
allowWorkspaceActions,
);

return (
Expand Down
4 changes: 3 additions & 1 deletion site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,9 @@ export const MockEntitlementsWithUserLimit: TypesGen.Entitlements = {
}),
};

export const MockExperiments: TypesGen.Experiment[] = ["workspace_actions"];
export const MockExperiments: TypesGen.Experiment[] = [
"deployment_health_page",
];

export const MockAuditLog: TypesGen.AuditLog = {
id: "fbd2116a-8961-4954-87ae-e4575bd29ce0",
Expand Down
Loading