Skip to content

Commit

Permalink
Modified annotation name and values
Browse files Browse the repository at this point in the history
  • Loading branch information
sabre1041 committed Jan 21, 2022
1 parent 2e4710f commit fb56e7d
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions controllers/egressipam/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ import (

const userAgent = "egressip-ipam-operator-services"

const AzureLoadBalancerAttachAnnotation = "egressip-ipam-operator.redhat-cop.io/azure-load-balancer-attach"
const AzureEgressLoadBalancerAnnotation = "egressip-ipam-operator.redhat-cop.io/azure-egress-load-balancer"

const (
AzureEgressLoadBalancerSameAsPrimaryIp AzureEgressLoadBalancer = "same-as-primary-ip"
AzureEgressLoadBalancerNone AzureEgressLoadBalancer = "none"
)

type AzureEgressLoadBalancer string

type AzureInfra struct {
//direct ocp client (not chached)
Expand Down Expand Up @@ -456,8 +463,11 @@ func (i *AzureInfra) addNeededAzureAssignedIPs(rc *reconcilecontext.ReconcileCon
}
}
}
if shouldAttachInternalLoadBalancerPool(rc.EgressIPAM) {
loadBalancerBackendAddressPools = (*networkInterface.IPConfigurations)[0].LoadBalancerBackendAddressPools
loadBalancerBackendAddressPools, err := getLoadBalancerPools(rc.EgressIPAM, networkInterface)
if err != nil {
i.log.Error(err, "unable to determine load balancer pools", "network interface", networkInterface.Name)
results <- err
return
}
ipConfigurations := *networkInterface.IPConfigurations
toBeAssignedIPs := strset.Difference(strset.New(ipsc...), strset.New(azureAssignedIPs...)).List()
Expand Down Expand Up @@ -550,13 +560,16 @@ func getResourceGroupFromResourceID(id string) string {
return strings.Split(id, "/")[4]
}

func shouldAttachInternalLoadBalancerPool(egresIPam *redhatcopv1alpha1.EgressIPAM) bool {
func getLoadBalancerPools(egresIPam *redhatcopv1alpha1.EgressIPAM, networkInterface network.Interface) (*[]network.BackendAddressPool, error) {

loadBalancerAttachAnnotation, ok := egresIPam.GetAnnotations()[AzureLoadBalancerAttachAnnotation]
// Check if Azure Egress Load Balancer annotation set to "none". Otherwise return the member of the pip
loadBalancerAttachAnnotation, ok := egresIPam.GetAnnotations()[AzureEgressLoadBalancerAnnotation]
if ok {
return loadBalancerAttachAnnotation != "false"
if string(AzureEgressLoadBalancerNone) == loadBalancerAttachAnnotation {
return nil, nil
}
}
return true
return (*networkInterface.IPConfigurations)[0].LoadBalancerBackendAddressPools, nil
}

// AzureMachineProviderSpec is the type that will be embedded in a Machine.Spec.ProviderSpec field
Expand Down

0 comments on commit fb56e7d

Please sign in to comment.