Skip to content

Commit

Permalink
fix: handle v2 http api exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
robot9706 committed Dec 16, 2024
1 parent 912d850 commit 3616c8d
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions web/crux/src/app/registry/registry-clients/v2-http-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,24 +414,36 @@ export default class V2HttpApiClient {
}

async fetchLabels(image: string, tag: string): Promise<Record<string, string>> {
const tagManifest = await this.fetchTagManifest(image, tag)
if (!tagManifest) {
try {
const tagManifest = await this.fetchTagManifest(image, tag)
if (!tagManifest) {
return {}
}

return this.fetchLabelsByManifest(image, tagManifest, 0)
} catch (err: any) {
this.logger.error(`Failed to fetch labels '${image}:${tag}'`)
this.logger.error(`${err.name} ${err.message}`, err.stack)
return {}
}

return this.fetchLabelsByManifest(image, tagManifest, 0)
}

async fetchTagInfo(image: string, tag: string): Promise<RegistryImageTag> {
const tagManifest = await this.fetchTagManifest(image, tag)
if (!tagManifest) {
return null
}
try {
const tagManifest = await this.fetchTagManifest(image, tag)
if (!tagManifest) {
return null
}

const configBlob = await this.fetchConfigBlobByManifest(image, tagManifest, 0)
const configBlob = await this.fetchConfigBlobByManifest(image, tagManifest, 0)

return {
created: configBlob.created,
return {
created: configBlob.created,
}
} catch (err: any) {
this.logger.error(`Failed to fetch tag info '${image}:${tag}'`)
this.logger.error(`${err.name} ${err.message}`, err.stack)
return null
}
}
}

0 comments on commit 3616c8d

Please sign in to comment.