Skip to content

Commit 5410981

Browse files
henrymercerCopilot
andcommitted
Address review feedback on the disk space check
Say "at or above" in the debug message logged when the check passes, since the comparison accepts exactly the minimum. Check each feature flag against the threshold its name declares, rather than only exercising a few of them, so that a mistake in one of the mappings cannot go unnoticed. Both sides of the boundary are needed to pin a threshold down: a mapping to a lower value would still pass the case at the limit, and one to a higher value would still fail the case below it. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 99caaa8 commit 5410981

3 files changed

Lines changed: 53 additions & 22 deletions

File tree

lib/entry-points.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.test.ts

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,26 +1333,57 @@ checkOverlayEnablementMacro.serial(
13331333
},
13341334
);
13351335

1336-
checkOverlayEnablementMacro.serial(
1337-
"Overlay-base database on default branch if runner disk space is above the limit lowered by a feature flag",
1338-
{
1339-
languages: [BuiltInLanguage.javascript],
1340-
features: [
1341-
Feature.OverlayAnalysis,
1342-
Feature.OverlayAnalysisCodeScanningJavascript,
1343-
Feature.OverlayAnalysisMinDisk10Gb,
1344-
],
1345-
isDefaultBranch: true,
1346-
diskUsage: {
1347-
numAvailableBytes: 11_000_000_000,
1348-
numTotalBytes: 100_000_000_000,
1336+
// Check that each feature flag lowers the limit to the threshold that its name
1337+
// declares. Both sides of the boundary are needed to pin the threshold down: a
1338+
// mapping to a lower value would still pass the case at the limit, and one to a
1339+
// higher value would still fail the case below it.
1340+
for (const [feature, thresholdGb] of [
1341+
[Feature.OverlayAnalysisMinDisk8Gb, 8],
1342+
[Feature.OverlayAnalysisMinDisk9Gb, 9],
1343+
[Feature.OverlayAnalysisMinDisk10Gb, 10],
1344+
[Feature.OverlayAnalysisMinDisk11Gb, 11],
1345+
[Feature.OverlayAnalysisMinDisk12Gb, 12],
1346+
[Feature.OverlayAnalysisMinDisk13Gb, 13],
1347+
] as Array<[Feature, number]>) {
1348+
const features = [
1349+
Feature.OverlayAnalysis,
1350+
Feature.OverlayAnalysisCodeScanningJavascript,
1351+
feature,
1352+
];
1353+
1354+
checkOverlayEnablementMacro.serial(
1355+
`Overlay-base database on default branch if ${feature} is enabled and runner disk space is at its limit`,
1356+
{
1357+
languages: [BuiltInLanguage.javascript],
1358+
features,
1359+
isDefaultBranch: true,
1360+
diskUsage: {
1361+
numAvailableBytes: thresholdGb * 1_000_000_000,
1362+
numTotalBytes: 100_000_000_000,
1363+
},
13491364
},
1350-
},
1351-
{
1352-
overlayDatabaseMode: OverlayDatabaseMode.OverlayBase,
1353-
useOverlayDatabaseCaching: true,
1354-
},
1355-
);
1365+
{
1366+
overlayDatabaseMode: OverlayDatabaseMode.OverlayBase,
1367+
useOverlayDatabaseCaching: true,
1368+
},
1369+
);
1370+
1371+
checkOverlayEnablementMacro.serial(
1372+
`No overlay-base database on default branch if ${feature} is enabled and runner disk space is below its limit`,
1373+
{
1374+
languages: [BuiltInLanguage.javascript],
1375+
features,
1376+
isDefaultBranch: true,
1377+
diskUsage: {
1378+
numAvailableBytes: thresholdGb * 1_000_000_000 - 1_000_000,
1379+
numTotalBytes: 100_000_000_000,
1380+
},
1381+
},
1382+
{
1383+
disabledReason: OverlayDisabledReason.InsufficientDiskSpace,
1384+
},
1385+
);
1386+
}
13561387

13571388
checkOverlayEnablementMacro.serial(
13581389
"Overlay-base database on default branch if runner disk space is exactly at the lowest limit enabled by a feature flag",

src/config-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ function runnerHasSufficientDiskSpace(
630630
}
631631

632632
logger.debug(
633-
`Disk space available for CodeQL analysis is ${diskSpaceMb} MB, which is above the minimum ` +
634-
`of ${minimumDiskSpaceMb} MB.`,
633+
`Disk space available for CodeQL analysis is ${diskSpaceMb} MB, which is at or above the ` +
634+
`minimum of ${minimumDiskSpaceMb} MB.`,
635635
);
636636
return true;
637637
}

0 commit comments

Comments
 (0)