diff --git a/pkg/asset/installconfig/ibmcloud/client.go b/pkg/asset/installconfig/ibmcloud/client.go index cf0200d2e27..8258fe61097 100644 --- a/pkg/asset/installconfig/ibmcloud/client.go +++ b/pkg/asset/installconfig/ibmcloud/client.go @@ -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" @@ -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 @@ -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 { diff --git a/pkg/asset/installconfig/ibmcloud/metadata.go b/pkg/asset/installconfig/ibmcloud/metadata.go index 71913e95758..1ce8d414897 100644 --- a/pkg/asset/installconfig/ibmcloud/metadata.go +++ b/pkg/asset/installconfig/ibmcloud/metadata.go @@ -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