Skip to content

Commit a5b1a58

Browse files
committed
try handling registry error gracefuly and see what happens
1 parent 5abfc0d commit a5b1a58

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
audience: general
2+
level: patch
3+
---
4+
5+
Add error handling for docker image release process.

infrastructure/tooling/src/build/tasks/monoimage.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@ const generateMonoimageTasks = ({ tasks, baseDir, cmdOptions, credentials, logsD
5757

5858
const imageLocal = (await dockerImages({ baseDir }))
5959
.some(image => image.RepoTags && image.RepoTags.indexOf(tag) !== -1);
60-
const imageOnRegistry = await dockerRegistryCheck({ tag });
61-
utils.status({ message: `Image does ${imageOnRegistry ? '' : 'not '} exist on registry` });
60+
61+
let imageOnRegistry;
62+
try {
63+
imageOnRegistry = await dockerRegistryCheck({ tag });
64+
utils.status({ message: `Image does ${imageOnRegistry ? '' : 'not '} exist on registry` });
65+
} catch (err) {
66+
utils.status({ message: `Error fetching image on registry: ${err.message}` });
67+
}
6268

6369
const provides = {
6470
'monoimage-docker-image': tag,
@@ -120,7 +126,14 @@ const generateMonoimageTasks = ({ tasks, baseDir, cmdOptions, credentials, logsD
120126

121127
const imageLocal = (await dockerImages({ baseDir }))
122128
.some(image => image.RepoTags && image.RepoTags.indexOf(tag) !== -1);
123-
const imageOnRegistry = await dockerRegistryCheck({ tag });
129+
130+
let imageOnRegistry;
131+
try {
132+
imageOnRegistry = await dockerRegistryCheck({ tag });
133+
utils.status({ message: `Image does ${imageOnRegistry ? '' : 'not '} exist on registry` });
134+
} catch (err) {
135+
utils.status({ message: `Error fetching image on registry: ${err.message}` });
136+
}
124137
utils.status({ message: `Image does ${imageOnRegistry ? '' : 'not '} exist on registry` });
125138

126139
const provides = {

infrastructure/tooling/src/utils/docker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,12 @@ exports.dockerImages = async ({ baseDir }) => {
225225
*/
226226
exports.dockerRegistryCheck = async ({ tag }) => {
227227
const [repo, imagetag] = tag.split(/:/);
228+
228229
try {
229230
// Access the registry API directly to see if this tag already exists, and do not push if so.
230231
const res = await got(`https://hub.docker.com/v2/repositories/taskcluster/${repo}/tags`, { responseType: 'json' });
231232
if (!res.body) {
232-
throw new Error('invalid response from index.docker.io');
233+
throw new Error('invalid response from hub.docker.com');
233234
}
234235
if (res.body.map(l => l.name).includes(imagetag)) {
235236
return true;

0 commit comments

Comments
 (0)