Skip to content

Commit

Permalink
Fix PowerVS cluster's load balancer status check (#2029)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dharaneeshvrd authored Oct 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent c3bf8d8 commit 9b07704
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cloud/scope/powervs_cluster.go
Original file line number Diff line number Diff line change
@@ -1955,6 +1955,8 @@ func (s *PowerVSClusterScope) ReconcileLoadBalancers() (bool, error) {
loadBalancers = append(loadBalancers, s.IBMPowerVSCluster.Spec.LoadBalancers...)
}

isAnyLoadBalancerNotReady := false

for index, loadBalancer := range loadBalancers {
var loadBalancerID *string
if loadBalancer.ID != nil {
@@ -1974,8 +1976,9 @@ func (s *PowerVSClusterScope) ReconcileLoadBalancers() (bool, error) {
return false, err
}

if requeue := s.checkLoadBalancerStatus(*loadBalancer); requeue {
return requeue, nil
if isReady := s.checkLoadBalancerStatus(*loadBalancer); !isReady {
s.V(3).Info("LoadBalancer is still not Active", "name", *loadBalancer.Name, "state", *loadBalancer.ProvisioningStatus)
isAnyLoadBalancerNotReady = true
}

loadBalancerStatus := infrav1beta2.VPCLoadBalancerStatus{
@@ -2012,25 +2015,26 @@ func (s *PowerVSClusterScope) ReconcileLoadBalancers() (bool, error) {
}
s.Info("Created VPC load balancer", "loadBalancerID", loadBalancerStatus.ID)
s.SetLoadBalancerStatus(loadBalancer.Name, *loadBalancerStatus)
isAnyLoadBalancerNotReady = true
}
if isAnyLoadBalancerNotReady {
return false, nil
}
return true, nil
}

// checkLoadBalancerStatus checks the state of a VPC load balancer.
// If state is pending, true is returned indicating a requeue for reconciliation.
// In all other cases, it returns false.
// If state is active, true is returned, in all other cases, it returns false indicating that load balancer is still not ready.
func (s *PowerVSClusterScope) checkLoadBalancerStatus(lb vpcv1.LoadBalancer) bool {
s.V(3).Info("Checking the status of VPC load balancer", "name", *lb.Name)
switch *lb.ProvisioningStatus {
case string(infrav1beta2.VPCLoadBalancerStateActive):
s.V(3).Info("VPC load balancer is in active state")
return true
case string(infrav1beta2.VPCLoadBalancerStateCreatePending):
s.V(3).Info("VPC load balancer creation is in pending state")
return true
case string(infrav1beta2.VPCLoadBalancerStateUpdatePending):
s.V(3).Info("VPC load balancer is in updating state")
return true
}
return false
}

0 comments on commit 9b07704

Please sign in to comment.