Skip to content

Commit

Permalink
Merge pull request #9350 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…9183-to-release-4.14

[release-4.14] OCPBUGS-48196: IBMCloud: Ignore failed VPC regions
  • Loading branch information
openshift-merge-bot[bot] authored Feb 4, 2025
2 parents ae581db + 6336e4c commit d58eede
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pkg/asset/installconfig/ibmcloud/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/IBM/platform-services-go-sdk/resourcemanagerv2"
"github.com/IBM/vpc-go-sdk/vpcv1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/openshift/installer/pkg/asset/installconfig/ibmcloud/responses"
"github.com/openshift/installer/pkg/types"
Expand Down Expand Up @@ -482,8 +483,13 @@ func (c *Client) GetVPC(ctx context.Context, vpcID string) (*vpcv1.VPC, error) {
}

if vpc, detailedResponse, err := c.vpcAPI.GetVPC(c.vpcAPI.NewGetVPCOptions(vpcID)); err != nil {
if detailedResponse.GetStatusCode() != http.StatusNotFound {
return nil, err
if detailedResponse != nil {
// If the response code signifies the VPC was not found, simply move on to the next region; otherwise we log the response
if detailedResponse.GetStatusCode() != http.StatusNotFound {
logrus.Warnf("Unexpected response while checking VPC %s in %s region: %s", vpcID, *region.Name, detailedResponse)
}
} else {
logrus.Warnf("Failure collecting VPC %s in %s: %q", vpcID, *region.Name, err)
}
} else if vpc != nil {
return vpc, nil
Expand Down Expand Up @@ -530,10 +536,14 @@ func (c *Client) GetVPCByName(ctx context.Context, vpcName string) (*vpcv1.VPC,
return nil, errors.Wrap(err, "failed to set vpc api service url")
}

vpcs, detailedResponse, err := c.vpcAPI.ListVpcsWithContext(ctx, c.vpcAPI.NewListVpcsOptions())
if err != nil {
if detailedResponse.GetStatusCode() != http.StatusNotFound {
return nil, err
if vpcs, detailedResponse, err := c.vpcAPI.ListVpcsWithContext(ctx, c.vpcAPI.NewListVpcsOptions()); err != nil {
if detailedResponse != nil {
// If the response code signifies no VPCs were not found, we simply move on to the next region; otherwise log the response
if detailedResponse.GetStatusCode() != http.StatusNotFound {
logrus.Warnf("Unexpected response while checking %s region: %s", *region.Name, detailedResponse)
}
} else {
logrus.Warnf("Failure collecting VPCs in %s: %q", *region.Name, err)
}
} else {
for _, vpc := range vpcs.Vpcs {
Expand Down
3 changes: 3 additions & 0 deletions pkg/asset/installconfig/ibmcloud/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ func (m *Metadata) IsVPCPermittedNetwork(ctx context.Context, vpcName string) (b
}

vpc, err := client.GetVPCByName(ctx, vpcName)
if err != nil {
return false, err
}
for _, network := range networks {
if network == *vpc.CRN {
return true, nil
Expand Down

0 comments on commit d58eede

Please sign in to comment.