Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ever-growing log messages with overlapping fields #4302

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AzureCluster is already set below if necessary.

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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log was never getting used but the side effects from this WithValues would have persisted after this loop which doesn't seem right.


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 @@
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 @@
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 @@
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