@@ -1955,6 +1955,8 @@ func (s *PowerVSClusterScope) ReconcileLoadBalancers() (bool, error) {
19551955 loadBalancers = append (loadBalancers , s .IBMPowerVSCluster .Spec .LoadBalancers ... )
19561956 }
19571957
1958+ isAnyLoadBalancerNotReady := false
1959+
19581960 for index , loadBalancer := range loadBalancers {
19591961 var loadBalancerID * string
19601962 if loadBalancer .ID != nil {
@@ -1974,8 +1976,9 @@ func (s *PowerVSClusterScope) ReconcileLoadBalancers() (bool, error) {
19741976 return false , err
19751977 }
19761978
1977- if requeue := s .checkLoadBalancerStatus (* loadBalancer ); requeue {
1978- return requeue , nil
1979+ if isReady := s .checkLoadBalancerStatus (* loadBalancer ); ! isReady {
1980+ s .V (3 ).Info ("LoadBalancer is still not Active" , "name" , * loadBalancer .Name , "state" , * loadBalancer .ProvisioningStatus )
1981+ isAnyLoadBalancerNotReady = true
19791982 }
19801983
19811984 loadBalancerStatus := infrav1beta2.VPCLoadBalancerStatus {
@@ -2012,25 +2015,26 @@ func (s *PowerVSClusterScope) ReconcileLoadBalancers() (bool, error) {
20122015 }
20132016 s .Info ("Created VPC load balancer" , "loadBalancerID" , loadBalancerStatus .ID )
20142017 s .SetLoadBalancerStatus (loadBalancer .Name , * loadBalancerStatus )
2018+ isAnyLoadBalancerNotReady = true
2019+ }
2020+ if isAnyLoadBalancerNotReady {
20152021 return false , nil
20162022 }
20172023 return true , nil
20182024}
20192025
20202026// checkLoadBalancerStatus checks the state of a VPC load balancer.
2021- // If state is pending, true is returned indicating a requeue for reconciliation.
2022- // In all other cases, it returns false.
2027+ // If state is active, true is returned, in all other cases, it returns false indicating that load balancer is still not ready.
20232028func (s * PowerVSClusterScope ) checkLoadBalancerStatus (lb vpcv1.LoadBalancer ) bool {
20242029 s .V (3 ).Info ("Checking the status of VPC load balancer" , "name" , * lb .Name )
20252030 switch * lb .ProvisioningStatus {
20262031 case string (infrav1beta2 .VPCLoadBalancerStateActive ):
20272032 s .V (3 ).Info ("VPC load balancer is in active state" )
2033+ return true
20282034 case string (infrav1beta2 .VPCLoadBalancerStateCreatePending ):
20292035 s .V (3 ).Info ("VPC load balancer creation is in pending state" )
2030- return true
20312036 case string (infrav1beta2 .VPCLoadBalancerStateUpdatePending ):
20322037 s .V (3 ).Info ("VPC load balancer is in updating state" )
2033- return true
20342038 }
20352039 return false
20362040}
0 commit comments