Skip to content

Commit

Permalink
Check if infra.Status.PlatformStatus exists before accessing it
Browse files Browse the repository at this point in the history
  • Loading branch information
rcarrillocruz committed Nov 27, 2019
1 parent 8f2a52f commit 37d8646
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions pkg/util/proxyconfig/no_proxy.go
Expand Up @@ -62,25 +62,27 @@ func MergeUserSystemNoProxy(proxy *configv1.Proxy, infra *configv1.Infrastructur
return "", fmt.Errorf("serviceNetwork missing from network '%s' status", network.Name)
}

switch infra.Status.PlatformStatus.Type {
case configv1.AWSPlatformType, configv1.GCPPlatformType, configv1.AzurePlatformType, configv1.OpenStackPlatformType:
set.Insert("169.254.169.254")
}
if infra.Status.PlatformStatus != nil {
switch infra.Status.PlatformStatus.Type {
case configv1.AWSPlatformType, configv1.GCPPlatformType, configv1.AzurePlatformType, configv1.OpenStackPlatformType:
set.Insert("169.254.169.254")
}

// Construct the node sub domain.
// TODO: Add support for additional cloud providers.
switch infra.Status.PlatformStatus.Type {
case configv1.AWSPlatformType:
region := infra.Status.PlatformStatus.AWS.Region
if region == "us-east-1" {
set.Insert(".ec2.internal")
} else {
set.Insert(fmt.Sprintf(".%s.compute.internal", region))
// Construct the node sub domain.
// TODO: Add support for additional cloud providers.
switch infra.Status.PlatformStatus.Type {
case configv1.AWSPlatformType:
region := infra.Status.PlatformStatus.AWS.Region
if region == "us-east-1" {
set.Insert(".ec2.internal")
} else {
set.Insert(fmt.Sprintf(".%s.compute.internal", region))
}
case configv1.GCPPlatformType:
// From https://cloud.google.com/vpc/docs/special-configurations add GCP metadata.
// "metadata.google.internal." added due to https://bugzilla.redhat.com/show_bug.cgi?id=1754049
set.Insert("metadata", "metadata.google.internal", "metadata.google.internal.")
}
case configv1.GCPPlatformType:
// From https://cloud.google.com/vpc/docs/special-configurations add GCP metadata.
// "metadata.google.internal." added due to https://bugzilla.redhat.com/show_bug.cgi?id=1754049
set.Insert("metadata", "metadata.google.internal", "metadata.google.internal.")
}

if len(ic.ControlPlane.Replicas) > 0 {
Expand Down

0 comments on commit 37d8646

Please sign in to comment.