-
Notifications
You must be signed in to change notification settings - Fork 928
fix: do not warn on valid known experiments #18514
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -972,7 +972,7 @@ func New(options *Options) *API { | |
}) | ||
r.Route("/experiments", func(r chi.Router) { | ||
r.Use(apiKeyMiddleware) | ||
r.Get("/available", handleExperimentsSafe) | ||
r.Get("/available", handleExperimentsAvailable) | ||
r.Get("/", api.handleExperimentsGet) | ||
}) | ||
r.Get("/updatecheck", api.updateCheck) | ||
|
@@ -1895,7 +1895,9 @@ func ReadExperiments(log slog.Logger, raw []string) codersdk.Experiments { | |
exps = append(exps, codersdk.ExperimentsSafe...) | ||
default: | ||
ex := codersdk.Experiment(strings.ToLower(v)) | ||
if !slice.Contains(codersdk.ExperimentsSafe, ex) { | ||
if !slice.Contains(codersdk.ExperimentsKnown, ex) { | ||
log.Warn(context.Background(), "ignoring unknown experiment", slog.F("experiment", ex)) | ||
} else if !slice.Contains(codersdk.ExperimentsSafe, ex) { | ||
Comment on lines
+1898
to
+1900
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍. |
||
log.Warn(context.Background(), "🐉 HERE BE DRAGONS: opting into hidden experiment", slog.F("experiment", ex)) | ||
} | ||
exps = append(exps, ex) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { API } from "api/api"; | ||
import type { Experiments } from "api/typesGenerated"; | ||
import { type Experiment, Experiments } from "api/typesGenerated"; | ||
import type { MetadataState } from "hooks/useEmbeddedMetadata"; | ||
import { cachedQuery } from "./util"; | ||
|
||
const experimentsKey = ["experiments"] as const; | ||
|
||
export const experiments = (metadata: MetadataState<Experiments>) => { | ||
export const experiments = (metadata: MetadataState<Experiment[]>) => { | ||
return cachedQuery({ | ||
metadata, | ||
queryKey: experimentsKey, | ||
|
@@ -19,3 +19,7 @@ export const availableExperiments = () => { | |
queryFn: async () => API.getAvailableExperiments(), | ||
}; | ||
}; | ||
|
||
export const isKnownExperiment = (experiment: string): boolean => { | ||
return Experiments.includes(experiment as Experiment); | ||
}; | ||
Comment on lines
+23
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, we could have the FE return the list of known experiments, but it seems silly to do this when we can just use the auto-generated type. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ const meta: Meta<typeof OverviewPageView> = { | |
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: ["workspace_actions"], | ||
value: ["example"], | ||
flag_shorthand: "", | ||
hidden: false, | ||
}, | ||
|
@@ -82,8 +82,8 @@ export const allExperimentsEnabled: Story = { | |
hidden: false, | ||
}, | ||
], | ||
safeExperiments: ["shared-ports"], | ||
invalidExperiments: ["invalid"], | ||
safeExperiments: ["example"], | ||
invalidExperiments: [], | ||
}, | ||
}; | ||
|
||
|
@@ -118,7 +118,7 @@ export const invalidExperimentsEnabled: Story = { | |
hidden: false, | ||
}, | ||
], | ||
safeExperiments: ["shared-ports"], | ||
safeExperiments: ["example"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. review: using the "example" experiment enum here instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense to me. Using a consistent experiment that we don't need to keep changing. I wonder if
|
||
invalidExperiments: ["invalid"], | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import AlertTitle from "@mui/material/AlertTitle"; | ||
import type { | ||
DAUsResponse, | ||
Experiments, | ||
Experiment, | ||
SerpentOption, | ||
} from "api/typesGenerated"; | ||
import { Link } from "components/Link/Link"; | ||
|
@@ -22,8 +22,8 @@ import { UserEngagementChart } from "./UserEngagementChart"; | |
type OverviewPageViewProps = { | ||
deploymentOptions: SerpentOption[]; | ||
dailyActiveUsers: DAUsResponse | undefined; | ||
readonly invalidExperiments: Experiments | string[]; | ||
readonly safeExperiments: Experiments | string[]; | ||
readonly invalidExperiments: readonly string[]; | ||
Comment on lines
23
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. review: this has to be a string because it might not be an Experiment |
||
readonly safeExperiments: readonly Experiment[]; | ||
}; | ||
|
||
export const OverviewPageView: FC<OverviewPageViewProps> = ({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda unfortunate we have
/available
that returns only the safe experiments. Ideally there would be a/available
and/safe
. Or just have/available
return amap[string]bool
where thebool
istrue
for safe or something.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I considered also returning all available experiments here but elected to keep the scope of this PR small.