Skip to content
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

[release-4.14] OCPBUGS-48196: IBMCloud: Ignore failed VPC regions #9350

Open
wants to merge 1 commit into
base: release-4.14
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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