Skip to content

Commit

Permalink
Tolerate failures in uploading debug artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Sep 16, 2024
1 parent d061f2c commit 80d7a6c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 44 deletions.
41 changes: 23 additions & 18 deletions lib/debug-artifacts.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/debug-artifacts.js.map

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

58 changes: 33 additions & 25 deletions src/debug-artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ function tryGetSarifResultPath(
}
} catch (e) {
logger.warning(
`Failed to find SARIF results path for ${language}. ${wrapError(e)}`,
`Failed to find SARIF results path for ${language}. ${
wrapError(e).message
}`,
);
}
return [];
Expand All @@ -113,7 +115,7 @@ async function tryBundleDatabase(
}
} catch (e) {
logger.warning(
`Failed to bundle database for ${language}. ${wrapError(e)}`,
`Failed to bundle database for ${language}. ${wrapError(e).message}`,
);
return [];
}
Expand All @@ -123,36 +125,42 @@ export async function uploadAllAvailableDebugArtifacts(
config: Config,
logger: Logger,
) {
const filesToUpload: string[] = [];
try {
const filesToUpload: string[] = [];

for (const language of config.languages) {
filesToUpload.push(...tryGetSarifResultPath(config, language, logger));

for (const language of config.languages) {
filesToUpload.push(...tryGetSarifResultPath(config, language, logger));
// Add any log files
const databaseDirectory = getCodeQLDatabasePath(config, language);
const logsDirectory = path.resolve(databaseDirectory, "log");
if (doesDirectoryExist(logsDirectory)) {
filesToUpload.push(...listFolder(logsDirectory));
}

// Add any log files
const databaseDirectory = getCodeQLDatabasePath(config, language);
const logsDirectory = path.resolve(databaseDirectory, "log");
if (doesDirectoryExist(logsDirectory)) {
filesToUpload.push(...listFolder(logsDirectory));
// Multilanguage tracing: there are additional logs in the root of the cluster
const multiLanguageTracingLogsDirectory = path.resolve(
config.dbLocation,
"log",
);
if (doesDirectoryExist(multiLanguageTracingLogsDirectory)) {
filesToUpload.push(...listFolder(multiLanguageTracingLogsDirectory));
}

// Add database bundle
filesToUpload.push(
...(await tryBundleDatabase(config, language, logger)),
);
}

// Multilanguage tracing: there are additional logs in the root of the cluster
const multiLanguageTracingLogsDirectory = path.resolve(
await uploadDebugArtifacts(
filesToUpload,
config.dbLocation,
"log",
config.debugArtifactName,
);
if (doesDirectoryExist(multiLanguageTracingLogsDirectory)) {
filesToUpload.push(...listFolder(multiLanguageTracingLogsDirectory));
}

// Add database bundle
filesToUpload.push(...(await tryBundleDatabase(config, language, logger)));
} catch (e) {
logger.warning(`Failed to upload debug artifacts: ${wrapError(e).message}`);
}

await uploadDebugArtifacts(
filesToUpload,
config.dbLocation,
config.debugArtifactName,
);
}

export async function uploadDebugArtifacts(
Expand Down

0 comments on commit 80d7a6c

Please sign in to comment.