Skip to content

Commit

Permalink
adding verbosity levels for loadbalancer.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Ana Runova committed Aug 10, 2023
1 parent 3c742d2 commit d84775f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pkg/cloud/services/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const loadBalancerProvisioningStatusActive = "ACTIVE"

func (s *Service) ReconcileLoadBalancer(openStackCluster *infrav1.OpenStackCluster, clusterName string, apiServerPort int) (bool, error) {
loadBalancerName := getLoadBalancerName(clusterName)
s.scope.Logger().Info("Reconciling load balancer", "name", loadBalancerName)
s.scope.Logger().V(3).Info("Reconciling load balancer", "name", loadBalancerName)

var fixedIPAddress string
switch {
Expand Down Expand Up @@ -169,7 +169,7 @@ func (s *Service) getOrCreateLoadBalancer(openStackCluster *infrav1.OpenStackClu
return lb, nil
}

s.scope.Logger().Info(fmt.Sprintf("Creating load balancer in subnet: %q", subnetID), "name", loadBalancerName)
s.scope.Logger().V(2).Info("Creating load balancer in subnet", "subnetID", subnetID, "name", loadBalancerName)

lbCreateOpts := loadbalancers.CreateOpts{
Name: loadBalancerName,
Expand Down Expand Up @@ -199,7 +199,7 @@ func (s *Service) getOrCreateListener(openStackCluster *infrav1.OpenStackCluster
return listener, nil
}

s.scope.Logger().Info("Creating load balancer listener", "name", listenerName, "lb-id", lbID)
s.scope.Logger().V(2).Info("Creating load balancer listener", "name", listenerName, "loadBalancerID", lbID)

listenerCreateOpts := listeners.CreateOpts{
Name: listenerName,
Expand Down Expand Up @@ -267,7 +267,7 @@ func (s *Service) getOrUpdateAllowedCIDRS(openStackCluster *infrav1.OpenStackClu
listener.AllowedCIDRs = capostrings.Unique(listener.AllowedCIDRs)

if !reflect.DeepEqual(allowedCIDRs, listener.AllowedCIDRs) {
s.scope.Logger().Info("CIDRs do not match, start to update listener", "expected CIDRs", allowedCIDRs, "load balancer existing CIDR", listener.AllowedCIDRs)
s.scope.Logger().V(3).Info("CIDRs do not match, updating listener", "expectedCIDRs", allowedCIDRs, "currentCIDRs", listener.AllowedCIDRs)
listenerUpdateOpts := listeners.UpdateOpts{
AllowedCIDRs: &allowedCIDRs,
}
Expand Down Expand Up @@ -316,7 +316,7 @@ func (s *Service) getOrCreatePool(openStackCluster *infrav1.OpenStackCluster, po
return pool, nil
}

s.scope.Logger().Info(fmt.Sprintf("Creating load balancer pool for listener %q", listenerID), "name", poolName, "lb-id", lbID)
s.scope.Logger().V(2).Info("Creating load balancer pool for listener", "loadBalancerID", lbID, "listenerID", listenerID, "name", poolName)

method := pools.LBMethodRoundRobin

Expand Down Expand Up @@ -356,7 +356,7 @@ func (s *Service) getOrCreateMonitor(openStackCluster *infrav1.OpenStackCluster,
return nil
}

s.scope.Logger().Info(fmt.Sprintf("Creating load balancer monitor for pool %q", poolID), "name", monitorName, "lb-id", lbID)
s.scope.Logger().V(2).Info("Creating load balancer monitor for pool", "loadBalancerID", lbID, "name", monitorName, "poolID", poolID)

monitorCreateOpts := monitors.CreateOpts{
Name: monitorName,
Expand Down Expand Up @@ -400,7 +400,7 @@ func (s *Service) ReconcileLoadBalancerMember(openStackCluster *infrav1.OpenStac
}

loadBalancerName := getLoadBalancerName(clusterName)
s.scope.Logger().Info("Reconciling load balancer member", "name", loadBalancerName)
s.scope.Logger().V(3).Info("Reconciling load balancer member", "loadBalancerName", loadBalancerName)

lbID := openStackCluster.Status.APIServerLoadBalancer.ID
portList := []int{int(openStackCluster.Spec.ControlPlaneEndpoint.Port)}
Expand Down Expand Up @@ -429,7 +429,7 @@ func (s *Service) ReconcileLoadBalancerMember(openStackCluster *infrav1.OpenStac
continue
}

s.scope.Logger().Info("Deleting load balancer member (because the IP of the machine changed)", "name", name)
s.scope.Logger().V(2).Info("Deleting load balancer member because the IP of the machine changed", "name", name)

// lb member changed so let's delete it so we can create it again with the correct IP
err = s.waitForLoadBalancerActive(lbID)
Expand All @@ -445,7 +445,7 @@ func (s *Service) ReconcileLoadBalancerMember(openStackCluster *infrav1.OpenStac
}
}

s.scope.Logger().Info("Creating load balancer member", "name", name)
s.scope.Logger().V(2).Info("Creating load balancer member", "name", name)

// if we got to this point we should either create or re-create the lb member
lbMemberOpts := pools.CreateMemberOpts{
Expand Down Expand Up @@ -500,7 +500,7 @@ func (s *Service) DeleteLoadBalancer(openStackCluster *infrav1.OpenStackCluster,
deleteOpts := loadbalancers.DeleteOpts{
Cascade: true,
}
s.scope.Logger().Info("Deleting load balancer", "name", loadBalancerName, "cascade", deleteOpts.Cascade)
s.scope.Logger().V(2).Info("Deleting load balancer", "name", loadBalancerName, "cascade", deleteOpts.Cascade)
err = s.loadbalancerClient.DeleteLoadBalancer(lb.ID, deleteOpts)
if err != nil && !capoerrors.IsNotFound(err) {
record.Warnf(openStackCluster, "FailedDeleteLoadBalancer", "Failed to delete load balancer %s with id %s: %v", lb.Name, lb.ID, err)
Expand Down Expand Up @@ -539,7 +539,7 @@ func (s *Service) DeleteLoadBalancerMember(openStackCluster *infrav1.OpenStackCl
return err
}
if pool == nil {
s.scope.Logger().Info("Load balancer pool does not exist", "name", lbPortObjectsName)
s.scope.Logger().V(4).Info("Load balancer pool does not exist", "name", lbPortObjectsName)
continue
}

Expand Down Expand Up @@ -634,7 +634,7 @@ var backoff = wait.Backoff{

// Possible LoadBalancer states are documented here: https://docs.openstack.org/api-ref/load-balancer/v2/index.html#prov-status
func (s *Service) waitForLoadBalancerActive(id string) error {
s.scope.Logger().Info("Waiting for load balancer", "id", id, "targetStatus", "ACTIVE")
s.scope.Logger().V(3).Info("Waiting for load balancer", "id", id, "targetStatus", "ACTIVE")
return wait.ExponentialBackoff(backoff, func() (bool, error) {
lb, err := s.loadbalancerClient.GetLoadBalancer(id)
if err != nil {
Expand All @@ -645,7 +645,7 @@ func (s *Service) waitForLoadBalancerActive(id string) error {
}

func (s *Service) waitForListener(id, target string) error {
s.scope.Logger().Info("Waiting for load balancer listener", "id", id, "targetStatus", target)
s.scope.Logger().V(3).Info("Waiting for load balancer listener", "id", id, "targetStatus", target)
return wait.ExponentialBackoff(backoff, func() (bool, error) {
_, err := s.loadbalancerClient.GetListener(id)
if err != nil {
Expand Down

0 comments on commit d84775f

Please sign in to comment.