Tolerate failures in uploading debug artifacts
This commit is contained in:
parent
d061f2cdd0
commit
80d7a6c8d4
3 changed files with 57 additions and 44 deletions
41
lib/debug-artifacts.js
generated
41
lib/debug-artifacts.js
generated
|
|
@ -87,7 +87,7 @@ function tryGetSarifResultPath(config, language, logger) {
|
|||
}
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning(`Failed to find SARIF results path for ${language}. ${(0, util_1.wrapError)(e)}`);
|
||||
logger.warning(`Failed to find SARIF results path for ${language}. ${(0, util_1.wrapError)(e).message}`);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
|
@ -101,29 +101,34 @@ async function tryBundleDatabase(config, language, logger) {
|
|||
}
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning(`Failed to bundle database for ${language}. ${(0, util_1.wrapError)(e)}`);
|
||||
logger.warning(`Failed to bundle database for ${language}. ${(0, util_1.wrapError)(e).message}`);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
async function uploadAllAvailableDebugArtifacts(config, logger) {
|
||||
const filesToUpload = [];
|
||||
for (const language of config.languages) {
|
||||
filesToUpload.push(...tryGetSarifResultPath(config, language, logger));
|
||||
// Add any log files
|
||||
const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language);
|
||||
const logsDirectory = path.resolve(databaseDirectory, "log");
|
||||
if ((0, util_1.doesDirectoryExist)(logsDirectory)) {
|
||||
filesToUpload.push(...(0, util_1.listFolder)(logsDirectory));
|
||||
try {
|
||||
const filesToUpload = [];
|
||||
for (const language of config.languages) {
|
||||
filesToUpload.push(...tryGetSarifResultPath(config, language, logger));
|
||||
// Add any log files
|
||||
const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language);
|
||||
const logsDirectory = path.resolve(databaseDirectory, "log");
|
||||
if ((0, util_1.doesDirectoryExist)(logsDirectory)) {
|
||||
filesToUpload.push(...(0, util_1.listFolder)(logsDirectory));
|
||||
}
|
||||
// Multilanguage tracing: there are additional logs in the root of the cluster
|
||||
const multiLanguageTracingLogsDirectory = path.resolve(config.dbLocation, "log");
|
||||
if ((0, util_1.doesDirectoryExist)(multiLanguageTracingLogsDirectory)) {
|
||||
filesToUpload.push(...(0, util_1.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(config.dbLocation, "log");
|
||||
if ((0, util_1.doesDirectoryExist)(multiLanguageTracingLogsDirectory)) {
|
||||
filesToUpload.push(...(0, util_1.listFolder)(multiLanguageTracingLogsDirectory));
|
||||
}
|
||||
// Add database bundle
|
||||
filesToUpload.push(...(await tryBundleDatabase(config, language, logger)));
|
||||
await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName);
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning(`Failed to upload debug artifacts: ${(0, util_1.wrapError)(e).message}`);
|
||||
}
|
||||
await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName);
|
||||
}
|
||||
async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
|
||||
if (toUpload.length === 0) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -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 [];
|
||||
|
|
@ -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 [];
|
||||
}
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue