Skip to content

Commit 9b07704

Browse files
Fix PowerVS cluster's load balancer status check (#2029)
Need to depend on load balancer's state to set the cluster's ready status instead of using requeue logic which is designed to block the reconciliation.
1 parent c3bf8d8 commit 9b07704

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cloud/scope/powervs_cluster.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -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.
20232028
func (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

Comments
 (0)