Skip to content

Commit 06ccea0

Browse files
committed
OCPBUGS-14963: IBMCloud: Ignore failed VPC regions
Ignore failures encountered when attempting to check VPC regions for resources. Simply log a warning message and move on, letting such checks fail eventually if the requested resources was in one such failed region. Related: https://issues.redhat.com/browse/OCPBUGS-14963
1 parent 916b3a3 commit 06ccea0

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

pkg/asset/installconfig/ibmcloud/client.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/IBM/platform-services-go-sdk/resourcemanagerv2"
2121
"github.com/IBM/vpc-go-sdk/vpcv1"
2222
"github.com/pkg/errors"
23+
"github.com/sirupsen/logrus"
2324

2425
configv1 "github.com/openshift/api/config/v1"
2526
"github.com/openshift/installer/pkg/asset/installconfig/ibmcloud/responses"
@@ -581,8 +582,13 @@ func (c *Client) GetVPC(ctx context.Context, vpcID string) (*vpcv1.VPC, error) {
581582
}
582583

583584
if vpc, detailedResponse, err := c.vpcAPI.GetVPC(c.vpcAPI.NewGetVPCOptions(vpcID)); err != nil {
584-
if detailedResponse.GetStatusCode() != http.StatusNotFound {
585-
return nil, err
585+
if detailedResponse != nil {
586+
// If the response code signifies the VPC was not found, simply move on to the next region; otherwise we log the response
587+
if detailedResponse.GetStatusCode() != http.StatusNotFound {
588+
logrus.Warnf("Unexpected response while checking VPC %s in %s region: %s", vpcID, *region.Name, detailedResponse)
589+
}
590+
} else {
591+
logrus.Warnf("Failure collecting VPC %s in %s: %q", vpcID, *region.Name, err)
586592
}
587593
} else if vpc != nil {
588594
return vpc, nil
@@ -629,10 +635,14 @@ func (c *Client) GetVPCByName(ctx context.Context, vpcName string) (*vpcv1.VPC,
629635
return nil, fmt.Errorf("failed to set vpc api service url: %w", err)
630636
}
631637

632-
vpcs, detailedResponse, err := c.vpcAPI.ListVpcsWithContext(ctx, c.vpcAPI.NewListVpcsOptions())
633-
if err != nil {
634-
if detailedResponse.GetStatusCode() != http.StatusNotFound {
635-
return nil, err
638+
if vpcs, detailedResponse, err := c.vpcAPI.ListVpcsWithContext(ctx, c.vpcAPI.NewListVpcsOptions()); err != nil {
639+
if detailedResponse != nil {
640+
// If the response code signifies no VPCs were not found, we simply move on to the next region; otherwise log the response
641+
if detailedResponse.GetStatusCode() != http.StatusNotFound {
642+
logrus.Warnf("Unexpected response while checking %s region: %s", *region.Name, detailedResponse)
643+
}
644+
} else {
645+
logrus.Warnf("Failure collecting VPCs in %s: %q", *region.Name, err)
636646
}
637647
} else {
638648
for _, vpc := range vpcs.Vpcs {

pkg/asset/installconfig/ibmcloud/metadata.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ func (m *Metadata) IsVPCPermittedNetwork(ctx context.Context, vpcName string) (b
173173
}
174174

175175
vpc, err := client.GetVPCByName(ctx, vpcName)
176+
if err != nil {
177+
return false, err
178+
}
176179
for _, network := range networks {
177180
if network == *vpc.CRN {
178181
return true, nil

0 commit comments

Comments
 (0)