Skip to content

Commit

Permalink
fix ever-growing log message with overlapping fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nojnhuh committed Nov 21, 2023
1 parent 67b1dc2 commit 8cd0171
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion controllers/asosecret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (asos *ASOSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request
)
defer done()

log = log.WithValues("namespace", req.Namespace, "AzureCluster", req.Name)
log = log.WithValues("namespace", req.Namespace)

// asoSecretOwner is the resource that created the identity. This could be either an AzureCluster or AzureManagedControlPlane (if AKS is enabled).
// check for AzureCluster first and if it is not found, check for AzureManagedControlPlane.
Expand Down
2 changes: 0 additions & 2 deletions controllers/azureidentity_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ func (r *AzureIdentityReconciler) Reconcile(ctx context.Context, req ctrl.Reques

var bindingsToDelete []aadpodv1.AzureIdentityBinding
for _, b := range bindings.Items {
log = log.WithValues("azureidentitybinding", b.Name)

binding := b
clusterName := binding.ObjectMeta.Labels[clusterv1.ClusterNameLabel]
clusterNamespace := binding.ObjectMeta.Labels[infrav1.ClusterLabelNamespace]
Expand Down
10 changes: 5 additions & 5 deletions controllers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func AzureClusterToAzureMachinesMapper(ctx context.Context, c client.Client, obj
return nil
}

log = log.WithValues("AzureCluster", azCluster.Name, "Namespace", azCluster.Namespace)
log := log.WithValues("AzureCluster", azCluster.Name, "Namespace", azCluster.Namespace)

// Don't handle deleted AzureClusters
if !azCluster.ObjectMeta.DeletionTimestamp.IsZero() {
Expand Down Expand Up @@ -750,7 +750,7 @@ func AzureManagedClusterToAzureManagedMachinePoolsMapper(ctx context.Context, c
return nil
}

log = log.WithValues("AzureManagedCluster", azCluster.Name, "Namespace", azCluster.Namespace)
log := log.WithValues("AzureManagedCluster", azCluster.Name, "Namespace", azCluster.Namespace)

// Don't handle deleted AzureManagedClusters
if !azCluster.ObjectMeta.DeletionTimestamp.IsZero() {
Expand Down Expand Up @@ -803,7 +803,7 @@ func AzureManagedControlPlaneToAzureManagedMachinePoolsMapper(ctx context.Contex
return nil
}

log = log.WithValues("AzureManagedControlPlane", azControlPlane.Name, "Namespace", azControlPlane.Namespace)
log := log.WithValues("AzureManagedControlPlane", azControlPlane.Name, "Namespace", azControlPlane.Namespace)

// Don't handle deleted AzureManagedControlPlanes
if !azControlPlane.ObjectMeta.DeletionTimestamp.IsZero() {
Expand Down Expand Up @@ -850,7 +850,7 @@ func AzureManagedClusterToAzureManagedControlPlaneMapper(ctx context.Context, c
return nil
}

log = log.WithValues("AzureManagedCluster", azCluster.Name, "Namespace", azCluster.Namespace)
log := log.WithValues("AzureManagedCluster", azCluster.Name, "Namespace", azCluster.Namespace)

// Don't handle deleted AzureManagedClusters
if !azCluster.ObjectMeta.DeletionTimestamp.IsZero() {
Expand Down Expand Up @@ -899,7 +899,7 @@ func AzureManagedControlPlaneToAzureManagedClusterMapper(ctx context.Context, c
return nil
}

log = log.WithValues("AzureManagedControlPlane", azManagedControlPlane.Name, "Namespace", azManagedControlPlane.Namespace)
log := log.WithValues("AzureManagedControlPlane", azManagedControlPlane.Name, "Namespace", azManagedControlPlane.Namespace)

// Don't handle deleted AzureManagedControlPlanes
if !azManagedControlPlane.ObjectMeta.DeletionTimestamp.IsZero() {
Expand Down
6 changes: 3 additions & 3 deletions exp/controllers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func AzureClusterToAzureMachinePoolsMapper(ctx context.Context, c client.Client,
return nil
}

log = log.WithValues("AzureCluster", azCluster.Name, "Namespace", azCluster.Namespace)
log := log.WithValues("AzureCluster", azCluster.Name, "Namespace", azCluster.Namespace)

// Don't handle deleted AzureClusters
if !azCluster.ObjectMeta.DeletionTimestamp.IsZero() {
Expand Down Expand Up @@ -116,7 +116,7 @@ func AzureManagedControlPlaneToAzureMachinePoolsMapper(ctx context.Context, c cl
return nil
}

log = log.WithValues("AzureManagedControlPlane", azControlPlane.Name, "Namespace", azControlPlane.Namespace)
log := log.WithValues("AzureManagedControlPlane", azControlPlane.Name, "Namespace", azControlPlane.Namespace)

Check warning on line 119 in exp/controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

exp/controllers/helpers.go#L119

Added line #L119 was not covered by tests

// Don't handle deleted AzureManagedControlPlane
if !azControlPlane.ObjectMeta.DeletionTimestamp.IsZero() {
Expand Down Expand Up @@ -165,7 +165,7 @@ func AzureMachinePoolMachineMapper(scheme *runtime.Scheme, log logr.Logger) hand
return nil
}

log = log.WithValues("AzureMachinePoolMachine", azureMachinePoolMachine.Name, "Namespace", azureMachinePoolMachine.Namespace)
log := log.WithValues("AzureMachinePoolMachine", azureMachinePoolMachine.Name, "Namespace", azureMachinePoolMachine.Namespace)

Check warning on line 168 in exp/controllers/helpers.go

View check run for this annotation

Codecov / codecov/patch

exp/controllers/helpers.go#L168

Added line #L168 was not covered by tests
for _, ref := range azureMachinePoolMachine.OwnerReferences {
if ref.Kind != gvk.Kind {
continue
Expand Down

0 comments on commit 8cd0171

Please sign in to comment.