-
Notifications
You must be signed in to change notification settings - Fork 452
Overlay: Fall back to full analysis if runner disk space is low #3310
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 1 commit
4f746e4
726a2a0
ed80d6e
4eccb37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
|---|---|---|
|
|
@@ -43,10 +43,22 @@ import { | |
| codeQlVersionAtLeast, | ||
| cloneObject, | ||
| isDefined, | ||
| checkDiskUsage, | ||
| } from "./util"; | ||
|
|
||
| export * from "./config/db-config"; | ||
|
|
||
| /** | ||
| * The minimum available disk space (in MB) required to perform overlay analysis. | ||
| * If the available disk space on the runner is below the threshold when deciding | ||
| * whether to perform overlay analysis, then the action will not perform overlay | ||
| * analysis unless overlay analysis has been explicitly enabled via environment | ||
| * variable. | ||
| */ | ||
| const OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_MB = 15000; | ||
| const OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_BYTES = | ||
| OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_MB * 1_000_000; | ||
|
|
||
| export type RegistryConfigWithCredentials = RegistryConfigNoCredentials & { | ||
| // Token to use when downloading packs from this registry. | ||
| token: string; | ||
|
|
@@ -667,28 +679,43 @@ export async function getOverlayDatabaseMode( | |
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| "from the CODEQL_OVERLAY_DATABASE_MODE environment variable.", | ||
| ); | ||
| } else if ( | ||
| await isOverlayAnalysisFeatureEnabled( | ||
| features, | ||
| codeql, | ||
| languages, | ||
| codeScanningConfig, | ||
| ) | ||
| ) { | ||
| if (isAnalyzingPullRequest()) { | ||
| overlayDatabaseMode = OverlayDatabaseMode.Overlay; | ||
| useOverlayDatabaseCaching = true; | ||
| logger.info( | ||
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| "with caching because we are analyzing a pull request.", | ||
| ); | ||
| } else if (await isAnalyzingDefaultBranch()) { | ||
| overlayDatabaseMode = OverlayDatabaseMode.OverlayBase; | ||
| useOverlayDatabaseCaching = true; | ||
| } else { | ||
| const diskUsage = await checkDiskUsage(logger); | ||
| if ( | ||
| diskUsage === undefined || | ||
| diskUsage.numAvailableBytes < OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_BYTES | ||
| ) { | ||
| const diskSpaceMb = | ||
| diskUsage === undefined ? 0 : diskUsage.numAvailableBytes / 1_000_000; | ||
| overlayDatabaseMode = OverlayDatabaseMode.None; | ||
| useOverlayDatabaseCaching = false; | ||
| logger.info( | ||
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| "with caching because we are analyzing the default branch.", | ||
| `due to insufficient disk space (${diskSpaceMb} MB).`, | ||
| ); | ||
|
mbg marked this conversation as resolved.
Outdated
|
||
| } else if ( | ||
| await isOverlayAnalysisFeatureEnabled( | ||
| features, | ||
| codeql, | ||
| languages, | ||
| codeScanningConfig, | ||
| ) | ||
| ) { | ||
| if (isAnalyzingPullRequest()) { | ||
| overlayDatabaseMode = OverlayDatabaseMode.Overlay; | ||
| useOverlayDatabaseCaching = true; | ||
| logger.info( | ||
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| "with caching because we are analyzing a pull request.", | ||
| ); | ||
| } else if (await isAnalyzingDefaultBranch()) { | ||
| overlayDatabaseMode = OverlayDatabaseMode.OverlayBase; | ||
| useOverlayDatabaseCaching = true; | ||
| logger.info( | ||
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| "with caching because we are analyzing the default branch.", | ||
| ); | ||
| } | ||
|
Comment on lines
+705
to
+720
Member
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. Minor: This could now just be two |
||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.