From b4c7ff50d3696fe9af15d2508cf43f6f38d15b73 Mon Sep 17 00:00:00 2001 From: Joel Diaz Date: Fri, 13 Mar 2020 11:24:37 -0400 Subject: [PATCH] handle old Infrastructure objects without PlatformStatus Older clusters that have been upgraded over time will have a corespondingly old verison of the Infrastructure CR where Status.PlatformStatus did not exist. Detect that case, and return an empty region string. The AWS client code will just use the defaults, and the permissions simulations will simply not include the region as part of the simulation. --- pkg/controller/utils/utils.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/controller/utils/utils.go b/pkg/controller/utils/utils.go index 9d0f4a244..765d91511 100644 --- a/pkg/controller/utils/utils.go +++ b/pkg/controller/utils/utils.go @@ -70,6 +70,12 @@ func LoadInfrastructureRegion(c client.Client, logger log.FieldLogger) (string, logger.WithError(err).Error("error loading Infrastructure region") return "", err } + if infra.Status.PlatformStatus == nil { + // Older clusters may have an Infrastructure object without the PlatformStatus fields. + // Send back an empty region and the AWS client will use default settings. + // The permissions simulation will also simply not fill out the region for simulations. + return "", nil + } return infra.Status.PlatformStatus.AWS.Region, nil }