Skip to content

Commit

Permalink
Fix scaling reserved RAM feature flag naming
Browse files Browse the repository at this point in the history
  • Loading branch information
henrymercer committed Jul 18, 2023
1 parent da4e0a0 commit 27d3b2f
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 12 deletions.
9 changes: 7 additions & 2 deletions lib/feature-flags.js

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

2 changes: 1 addition & 1 deletion lib/feature-flags.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions lib/feature-flags.test.js

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

2 changes: 1 addition & 1 deletion lib/feature-flags.test.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/util.js

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

2 changes: 1 addition & 1 deletion lib/util.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/util.test.js

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

2 changes: 1 addition & 1 deletion lib/util.test.js.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/feature-flags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,15 @@ test("ignores invalid version numbers in default version feature flags", async (
});
});

test("feature flags should end with _enabled", async (t) => {
for (const feature of Object.values(Feature)) {
t.assert(
feature.endsWith("_enabled"),
`${feature} should end with '_enabled'`
);
}
});

function assertAllFeaturesUndefinedInApi(
t: ExecutionContext<unknown>,
loggedMessages: LoggedMessage[]
Expand Down
9 changes: 7 additions & 2 deletions src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export interface FeatureEnablement {
getValue(feature: Feature, codeql?: CodeQL): Promise<boolean>;
}

/**
* Feature enablement as returned by the GitHub API endpoint.
*
* Each value of this enum should end with `_enabled`.
*/
export enum Feature {
CliConfigFileEnabled = "cli_config_file_enabled",
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
Expand All @@ -39,7 +44,7 @@ export enum Feature {
MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
NewAnalysisSummaryEnabled = "new_analysis_summary_enabled",
QaTelemetryEnabled = "qa_telemetry_enabled",
ScalingReservedRam = "scaling_reserved_ram",
ScalingReservedRamEnabled = "scaling_reserved_ram_enabled",
UploadFailedSarifEnabled = "upload_failed_sarif_enabled",
}

Expand Down Expand Up @@ -77,7 +82,7 @@ export const featureConfig: Record<
minimumVersion: undefined,
defaultValue: false,
},
[Feature.ScalingReservedRam]: {
[Feature.ScalingReservedRamEnabled]: {
envVar: "CODEQL_ACTION_SCALING_RESERVED_RAM",
minimumVersion: undefined,
defaultValue: false,
Expand Down
2 changes: 1 addition & 1 deletion src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test("getMemoryFlag() should return the correct --ram flag", async (t) => {

for (const [input, withScaling, expectedFlag] of tests) {
const features = createFeatures(
withScaling ? [Feature.ScalingReservedRam] : []
withScaling ? [Feature.ScalingReservedRamEnabled] : []
);
const flag = await util.getMemoryFlag(input, features);
t.deepEqual(flag, expectedFlag);
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async function getSystemReservedMemoryMegaBytes(
// Windows needs more memory for OS processes.
const fixedAmount = 1024 * (process.platform === "win32" ? 1.5 : 1);

if (await features.getValue(Feature.ScalingReservedRam)) {
if (await features.getValue(Feature.ScalingReservedRamEnabled)) {
// Reserve an additional 2% of the total memory, since the amount used by
// the kernel for page tables scales with the size of physical memory.
const scaledAmount = 0.02 * totalMemoryMegaBytes;
Expand Down

0 comments on commit 27d3b2f

Please sign in to comment.