Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.walther committed Sep 9, 2024
1 parent ba2c1f4 commit 50170b1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/envoy/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ func MapSnapshot(ctx context.Context, client ctrlclient.Client, loadBalancers []
var cluster []types.Resource

log := ctrl.LoggerFrom(ctx)
log.Info("Creating snapshot")
addressesMap := make(map[string][]kubelbv1alpha1.EndpointAddress)
for _, lb := range loadBalancers {
// multiple endpoints represent multiple clusters
log.V(2).Info("Adding load balancer", "name", lb.Name, "namespace", lb.Namespace)
log.Info("Adding load balancer", "name", lb.Name, "namespace", lb.Namespace)
for i, lbEndpoint := range lb.Spec.Endpoints {
log.V(2).Info("Adding endpoint", "name", lbEndpoint.AddressesReference.Name)
log.Info("Adding endpoint", "name", lbEndpoint.AddressesReference.Name)
if lbEndpoint.AddressesReference != nil {
// Check if map already contains the key
if val, ok := addressesMap[fmt.Sprintf(endpointAddressReferencePattern, lb.Namespace, lbEndpoint.AddressesReference.Name)]; ok {
Expand All @@ -80,7 +81,7 @@ func MapSnapshot(ctx context.Context, client ctrlclient.Client, loadBalancers []
}

for _, lbEndpointPort := range lbEndpoint.Ports {
log.V(2).Info("Adding port", "port", lbEndpointPort.Port, "protocol", lbEndpointPort.Protocol)
log.Info("Adding port", "port", lbEndpointPort.Port, "protocol", lbEndpointPort.Protocol)
var lbEndpoints []*envoyEndpoint.LbEndpoint
key := fmt.Sprintf(kubelb.EnvoyResourceIdentifierPattern, lb.Namespace, lb.Name, i, lbEndpointPort.Port, lbEndpointPort.Protocol)

Expand All @@ -103,7 +104,7 @@ func MapSnapshot(ctx context.Context, client ctrlclient.Client, loadBalancers []
} else if lbEndpointPort.Protocol == corev1.ProtocolUDP {
listener = append(listener, makeUDPListener(key, key, port))
}
log.V(2).Info("adding cluster", "key", key, "ports", len(lbEndpoint.Ports))
log.Info("adding cluster", "key", key, "ports", len(lbEndpoint.Ports))
cluster = append(cluster, makeCluster(key, lbEndpoints))
}

Expand Down

0 comments on commit 50170b1

Please sign in to comment.