-
Notifications
You must be signed in to change notification settings - Fork 62
Add fallback image pull from Azure #1618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,9 @@ export enum DependabotErrorType { | |
| UpdateRun = 'actions_workflow_updater' | ||
| } | ||
|
|
||
| const FALLBACK_CONTAINER_REGISTRY = | ||
| 'dependabot-acr-apim-production.azure-api.net' | ||
|
|
||
| let jobId: number | ||
|
|
||
| export async function run(context: Context): Promise<void> { | ||
|
|
@@ -70,8 +73,9 @@ export async function run(context: Context): Promise<void> { | |
| const details = await apiClient.getJobDetails() | ||
|
|
||
| // The dynamic workflow can specify which updater image to use. If it doesn't, fall back to the pinned version. | ||
| const updaterImage = | ||
| let updaterImage = | ||
| params.updaterImage || updaterImageName(details['package-manager']) | ||
| let proxyImage = PROXY_IMAGE_NAME | ||
|
|
||
| // The sendMetrics function is used to send metrics to the API client. | ||
| // It uses the package manager as a tag to identify the metric. | ||
|
|
@@ -105,36 +109,50 @@ export async function run(context: Context): Promise<void> { | |
| credentials.push(packagesCred) | ||
| } | ||
|
|
||
| const updater = new Updater( | ||
| updaterImage, | ||
| PROXY_IMAGE_NAME, | ||
| apiClient, | ||
| details, | ||
| credentials | ||
| ) | ||
|
|
||
| core.startGroup('Pulling updater images') | ||
| let imagesPulled = false | ||
|
|
||
| try { | ||
| // Using sendMetricsWithPackageManager wrapper to inject package manager tag ti | ||
| // avoid passing additional parameters to ImageService.pull method | ||
| await ImageService.pull(updaterImage, sendMetricsWithPackageManager) | ||
| await ImageService.pull(PROXY_IMAGE_NAME, sendMetricsWithPackageManager) | ||
| } catch (error: unknown) { | ||
| if (error instanceof Error) { | ||
| await failJob( | ||
| apiClient, | ||
| 'Error fetching updater images', | ||
| error, | ||
| DependabotErrorType.Image | ||
| ) | ||
| return | ||
| await ImageService.pull(proxyImage, sendMetricsWithPackageManager) | ||
| imagesPulled = true | ||
| } catch { | ||
| core.warning('Primary image pull failed, attempting fallback') | ||
| } | ||
|
Comment on lines
115
to
+123
|
||
|
|
||
| if (!imagesPulled) { | ||
| updaterImage = `${FALLBACK_CONTAINER_REGISTRY}/${updaterImage}` | ||
| proxyImage = `${FALLBACK_CONTAINER_REGISTRY}/${proxyImage}` | ||
| try { | ||
| await ImageService.pull(updaterImage, sendMetricsWithPackageManager) | ||
| await ImageService.pull(proxyImage, sendMetricsWithPackageManager) | ||
| } catch (error: unknown) { | ||
|
Comment on lines
112
to
+131
|
||
| if (error instanceof Error) { | ||
| await failJob( | ||
| apiClient, | ||
| 'Error fetching updater images', | ||
| error, | ||
| DependabotErrorType.Image | ||
| ) | ||
| return | ||
| } | ||
| } | ||
| } | ||
| core.endGroup() | ||
|
Comment on lines
112
to
143
|
||
|
|
||
| try { | ||
| core.info('Starting update process') | ||
|
|
||
| const updater = new Updater( | ||
| updaterImage, | ||
| proxyImage, | ||
| apiClient, | ||
| details, | ||
| credentials | ||
| ) | ||
|
|
||
| await updater.runUpdater() | ||
| } catch (error: unknown) { | ||
| if (error instanceof Error) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test exercises
fetchImageWithRetrywith anazure-api.netimage name, but the new repository allowlist behavior is enforced inImageService.pull()viavalidImageRepository(). Add a unit test that callsImageService.pull()with an*.azure-api.net/...image and asserts it does not throw (mocking Docker as needed), so the allowlist change is actually covered.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's necessary.