Skip to content

Commit 80d7a6c

Browse files
committed
Tolerate failures in uploading debug artifacts
1 parent d061f2c commit 80d7a6c

File tree

3 files changed

+57
-44
lines changed

3 files changed

+57
-44
lines changed

lib/debug-artifacts.js

Lines changed: 23 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/debug-artifacts.js.map

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/debug-artifacts.ts

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ function tryGetSarifResultPath(
9494
}
9595
} catch (e) {
9696
logger.warning(
97-
`Failed to find SARIF results path for ${language}. ${wrapError(e)}`,
97+
`Failed to find SARIF results path for ${language}. ${
98+
wrapError(e).message
99+
}`,
98100
);
99101
}
100102
return [];
@@ -113,7 +115,7 @@ async function tryBundleDatabase(
113115
}
114116
} catch (e) {
115117
logger.warning(
116-
`Failed to bundle database for ${language}. ${wrapError(e)}`,
118+
`Failed to bundle database for ${language}. ${wrapError(e).message}`,
117119
);
118120
return [];
119121
}
@@ -123,36 +125,42 @@ export async function uploadAllAvailableDebugArtifacts(
123125
config: Config,
124126
logger: Logger,
125127
) {
126-
const filesToUpload: string[] = [];
128+
try {
129+
const filesToUpload: string[] = [];
130+
131+
for (const language of config.languages) {
132+
filesToUpload.push(...tryGetSarifResultPath(config, language, logger));
127133

128-
for (const language of config.languages) {
129-
filesToUpload.push(...tryGetSarifResultPath(config, language, logger));
134+
// Add any log files
135+
const databaseDirectory = getCodeQLDatabasePath(config, language);
136+
const logsDirectory = path.resolve(databaseDirectory, "log");
137+
if (doesDirectoryExist(logsDirectory)) {
138+
filesToUpload.push(...listFolder(logsDirectory));
139+
}
130140

131-
// Add any log files
132-
const databaseDirectory = getCodeQLDatabasePath(config, language);
133-
const logsDirectory = path.resolve(databaseDirectory, "log");
134-
if (doesDirectoryExist(logsDirectory)) {
135-
filesToUpload.push(...listFolder(logsDirectory));
141+
// Multilanguage tracing: there are additional logs in the root of the cluster
142+
const multiLanguageTracingLogsDirectory = path.resolve(
143+
config.dbLocation,
144+
"log",
145+
);
146+
if (doesDirectoryExist(multiLanguageTracingLogsDirectory)) {
147+
filesToUpload.push(...listFolder(multiLanguageTracingLogsDirectory));
148+
}
149+
150+
// Add database bundle
151+
filesToUpload.push(
152+
...(await tryBundleDatabase(config, language, logger)),
153+
);
136154
}
137155

138-
// Multilanguage tracing: there are additional logs in the root of the cluster
139-
const multiLanguageTracingLogsDirectory = path.resolve(
156+
await uploadDebugArtifacts(
157+
filesToUpload,
140158
config.dbLocation,
141-
"log",
159+
config.debugArtifactName,
142160
);
143-
if (doesDirectoryExist(multiLanguageTracingLogsDirectory)) {
144-
filesToUpload.push(...listFolder(multiLanguageTracingLogsDirectory));
145-
}
146-
147-
// Add database bundle
148-
filesToUpload.push(...(await tryBundleDatabase(config, language, logger)));
161+
} catch (e) {
162+
logger.warning(`Failed to upload debug artifacts: ${wrapError(e).message}`);
149163
}
150-
151-
await uploadDebugArtifacts(
152-
filesToUpload,
153-
config.dbLocation,
154-
config.debugArtifactName,
155-
);
156164
}
157165

158166
export async function uploadDebugArtifacts(

0 commit comments

Comments
 (0)