Skip to content

Commit 155c12f

Browse files
committed
OCPBUGS-25191: ic: azure: fix retrieving marketplace image
When openshift#7778 replaced `errors.Wrap` by `fmt.Errorf` it introduced a bug when retrieving a marketplace image in the client interface because of their different behaviors. `errors.Wrap(err, ...)` returns `nil` when `err` is `nil` whereas `fmt.Errorf` always returns an error. Unfortunately this was not caught in the unit tests since the client calls are mocked. This bug resulted in the following error: ``` ERROR failed to fetch Master Machines: failed to load asset "Install Config": failed to create install config: [controlPlane.platform.azure.osImage: Invalid value: azure.OSImage{Plan:"", Publisher:"redhat", Offer:"rh-ocp-worker", SKU:"rh-ocp-worker", Version:"413.92.2023101700"}: could not get marketplace image: %!w(<nil>), compute[0].platform.azure.osImage: Invalid value: azure.OSImage{Plan:"", Publisher:"redhat", Offer:"rh-ocp-worker", SKU:"rh-ocp-worker", Version:"413.92.2023101700"}: could not get marketplace image: %!w(<nil>)] ```
1 parent 271f256 commit 155c12f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/asset/installconfig/azure/client.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ func (c *Client) GetMarketplaceImage(ctx context.Context, region, publisher, off
330330
defer cancel()
331331

332332
image, err := client.Get(ctx, region, publisher, offer, sku, version)
333-
return image, fmt.Errorf("could not get marketplace image: %w", err)
333+
if err != nil {
334+
return image, fmt.Errorf("could not get marketplace image: %w", err)
335+
}
336+
return image, nil
334337
}
335338

336339
// AreMarketplaceImageTermsAccepted tests whether the terms have been accepted for the specified marketplace VM image.

0 commit comments

Comments
 (0)