Skip to content

chore: remove template_update_policies experiment #11250

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 9 commits into from
Dec 21, 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
9 changes: 0 additions & 9 deletions cli/templatecreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ func (r *RootCmd) templateCreate() *clibase.Cmd {
if !entitlements.Features[codersdk.FeatureAccessControl].Enabled {
return xerrors.Errorf("your license is not entitled to use enterprise access control, so you cannot set --require-active-version")
}

experiments, exErr := client.Experiments(inv.Context())
if exErr != nil {
return xerrors.Errorf("get experiments: %w", exErr)
}

if !experiments.Enabled(codersdk.ExperimentTemplateUpdatePolicies) {
return xerrors.Errorf("--require-active-version is an experimental feature, contact an administrator to enable the 'template_update_policies' experiment on your Coder server")
}
}
}

Expand Down
7 changes: 0 additions & 7 deletions cli/templatecreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/coderd/coderdtest"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/provisioner/echo"
"github.com/coder/coder/v2/provisionersdk/proto"
"github.com/coder/coder/v2/pty/ptytest"
Expand Down Expand Up @@ -398,14 +397,8 @@ func TestTemplateCreate(t *testing.T) {
t.Run("RequireActiveVersionInvalid", func(t *testing.T) {
t.Parallel()

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

client := coderdtest.New(t, &coderdtest.Options{
IncludeProvisionerDaemon: true,
DeploymentValues: dv,
})
coderdtest.CreateFirstUser(t, client)
source := clitest.CreateTemplateVersionSource(t, completeWithAgent())
Expand Down
9 changes: 0 additions & 9 deletions cli/templateedit.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ func (r *RootCmd) templateEdit() *clibase.Cmd {
if !entitlements.Features[codersdk.FeatureAccessControl].Enabled {
return xerrors.Errorf("your license is not entitled to use enterprise access control, so you cannot set --require-active-version")
}

experiments, exErr := client.Experiments(inv.Context())
if exErr != nil {
return xerrors.Errorf("get experiments: %w", exErr)
}

if !experiments.Enabled(codersdk.ExperimentTemplateUpdatePolicies) {
return xerrors.Errorf("--require-active-version is an experimental feature, contact an administrator to enable the 'template_update_policies' experiment on your Coder server")
}
}
}

Expand Down
6 changes: 2 additions & 4 deletions coderd/apidoc/docs.go

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

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

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

1 change: 0 additions & 1 deletion codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2088,7 +2088,6 @@ const (
// Deployment health page
ExperimentDeploymentHealthPage Experiment = "deployment_health_page"

ExperimentTemplateUpdatePolicies Experiment = "template_update_policies"
// Add new experiments here!
// ExperimentExample Experiment = "example"
)
Expand Down
13 changes: 6 additions & 7 deletions docs/api/schemas.md

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

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

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

client, user := coderdenttest.New(t, &coderdenttest.Options{
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureAccessControl: 1,
},
},
Options: &coderdtest.Options{
DeploymentValues: dv,
IncludeProvisionerDaemon: true,
},
})
Expand Down Expand Up @@ -124,17 +118,11 @@ func TestTemplateCreate(t *testing.T) {
t.Run("NotEntitled", func(t *testing.T) {
t.Parallel()

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

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

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

ownerClient, owner := coderdenttest.New(t, &coderdenttest.Options{
LicenseOptions: &coderdenttest.LicenseOptions{
Features: license.Features{
codersdk.FeatureAccessControl: 1,
},
},
Options: &coderdtest.Options{
DeploymentValues: dv,
IncludeProvisionerDaemon: true,
},
})
Expand Down Expand Up @@ -64,17 +58,11 @@ func TestTemplateEdit(t *testing.T) {
t.Run("NotEntitled", func(t *testing.T) {
t.Parallel()

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

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

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

8 changes: 0 additions & 8 deletions site/src/components/Dashboard/DashboardProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,3 @@ export const useIsWorkspaceActionsEnabled = (): boolean => {
const allowWorkspaceActions = experiments.includes("workspace_actions");
return allowWorkspaceActions && allowAdvancedScheduling;
};

export const useTemplatePoliciesEnabled = (): boolean => {
const { entitlements, experiments } = useDashboard();
return (
entitlements.features.access_control.enabled &&
experiments.includes("template_update_policies")
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export interface TemplateSettingsForm {
// Helpful to show field errors on Storybook
initialTouched?: FormikTouched<UpdateTemplateMeta>;
accessControlEnabled: boolean;
templatePoliciesEnabled: boolean;
}

export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
Expand All @@ -63,7 +62,6 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
isSubmitting,
initialTouched,
accessControlEnabled,
templatePoliciesEnabled,
}) => {
const validationSchema = getValidationSchema();
const form: FormikContextType<UpdateTemplateMeta> =
Expand Down Expand Up @@ -180,41 +178,39 @@ export const TemplateSettingsForm: FC<TemplateSettingsForm> = ({
</Stack>
</Stack>
</label>
{templatePoliciesEnabled && (
<label htmlFor="require_active_version">
<Stack direction="row" spacing={1}>
<Checkbox
id="require_active_version"
name="require_active_version"
checked={form.values.require_active_version}
onChange={form.handleChange}
/>
<label htmlFor="require_active_version">
<Stack direction="row" spacing={1}>
<Checkbox
id="require_active_version"
name="require_active_version"
checked={form.values.require_active_version}
onChange={form.handleChange}
/>

<Stack direction="column" spacing={0.5}>
<Stack
direction="row"
alignItems="center"
spacing={0.5}
css={styles.optionText}
>
Require workspaces automatically update when started.
<HelpTooltip>
<HelpTooltipTrigger />
<HelpTooltipContent>
<HelpTooltipText>
This setting is not enforced for template admins.
</HelpTooltipText>
</HelpTooltipContent>
</HelpTooltip>
</Stack>
<span css={styles.optionHelperText}>
Workspaces that are manually started or auto-started will
use the active template version.
</span>
<Stack direction="column" spacing={0.5}>
<Stack
direction="row"
alignItems="center"
spacing={0.5}
css={styles.optionText}
>
Require workspaces automatically update when started.
<HelpTooltip>
<HelpTooltipTrigger />
<HelpTooltipContent>
<HelpTooltipText>
This setting is not enforced for template admins.
</HelpTooltipText>
</HelpTooltipContent>
</HelpTooltip>
</Stack>
<span css={styles.optionHelperText}>
Workspaces that are manually started or auto-started will use
the active template version.
</span>
</Stack>
</label>
)}
</Stack>
</label>
</Stack>
</FormSection>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ const fillAndSubmitForm = async ({
await userEvent.clear(iconField);
await userEvent.type(iconField, icon);

const allowCancelJobsField = screen.getByRole("checkbox");
const allowCancelJobsField = screen.getByRole("checkbox", {
name: "Allow users to cancel in-progress workspace jobs. Depending on your template, canceling builds may leave workspaces in an unhealthy state. This option isn't recommended for most use cases.",
});
// checkbox is checked by default, so it must be clicked to get unchecked
if (!allow_user_cancel_workspace_jobs) {
await userEvent.click(allowCancelJobsField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import { useTemplateSettings } from "../TemplateSettingsLayout";
import { TemplateSettingsPageView } from "./TemplateSettingsPageView";
import { templateByNameKey } from "api/queries/templates";
import { useOrganizationId } from "hooks";
import {
useDashboard,
useTemplatePoliciesEnabled,
} from "components/Dashboard/DashboardProvider";
import { useDashboard } from "components/Dashboard/DashboardProvider";

export const TemplateSettingsPage: FC = () => {
const { template: templateName } = useParams() as { template: string };
Expand All @@ -23,7 +20,6 @@ export const TemplateSettingsPage: FC = () => {
const queryClient = useQueryClient();
const { entitlements } = useDashboard();
const accessControlEnabled = entitlements.features.access_control.enabled;
const templatePoliciesEnabled = useTemplatePoliciesEnabled();

const {
mutate: updateTemplate,
Expand Down Expand Up @@ -62,7 +58,6 @@ export const TemplateSettingsPage: FC = () => {
});
}}
accessControlEnabled={accessControlEnabled}
templatePoliciesEnabled={templatePoliciesEnabled}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const meta: Meta<typeof TemplateSettingsPageView> = {
args: {
template: MockTemplate,
accessControlEnabled: true,
templatePoliciesEnabled: true,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface TemplateSettingsPageViewProps {
typeof TemplateSettingsForm
>["initialTouched"];
accessControlEnabled: boolean;
templatePoliciesEnabled: boolean;
}

export const TemplateSettingsPageView: FC<TemplateSettingsPageViewProps> = ({
Expand All @@ -24,7 +23,6 @@ export const TemplateSettingsPageView: FC<TemplateSettingsPageViewProps> = ({
submitError,
initialTouched,
accessControlEnabled,
templatePoliciesEnabled,
}) => {
return (
<>
Expand All @@ -40,7 +38,6 @@ export const TemplateSettingsPageView: FC<TemplateSettingsPageViewProps> = ({
onCancel={onCancel}
error={submitError}
accessControlEnabled={accessControlEnabled}
templatePoliciesEnabled={templatePoliciesEnabled}
/>
</>
);
Expand Down
Loading