Skip to content

Commit ece9de4

Browse files
authored
Merge pull request #7087 from killianmuldoon/logs/update-type-casing
🌱 Logs/update type casing
2 parents a08192f + d2c5142 commit ece9de4

File tree

9 files changed

+16
-13
lines changed

9 files changed

+16
-13
lines changed

controlplane/kubeadm/internal/controllers/remediation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (r *KubeadmControlPlaneReconciler) reconcileUnhealthyMachines(ctx context.C
9898
if err := patchHelper.Patch(ctx, machineToBeRemediated, patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
9999
clusterv1.MachineOwnerRemediatedCondition,
100100
}}); err != nil {
101-
log.Error(err, "Failed to patch control plane Machine", "machine", machineToBeRemediated.Name)
101+
log.Error(err, "Failed to patch control plane Machine", "Machine", machineToBeRemediated.Name)
102102
if retErr == nil {
103103
retErr = errors.Wrapf(err, "failed to patch control plane Machine %s", machineToBeRemediated.Name)
104104
}

exp/runtime/internal/controllers/warmup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func warmupRegistry(ctx context.Context, client client.Client, reader client.Rea
103103
extensionConfig := &extensionConfigList.Items[i]
104104
original := extensionConfig.DeepCopy()
105105

106-
log := log.WithValues("extensionConfig", klog.KObj(extensionConfig), "name", extensionConfig.Name, "namespace", extensionConfig.Namespace)
106+
log := log.WithValues("ExtensionConfig", klog.KObj(extensionConfig))
107107
ctx := ctrl.LoggerInto(ctx, log)
108108

109109
// Inject CABundle from secret if annotation is set. Otherwise https calls may fail.

exp/util/util.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/pkg/errors"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/apimachinery/pkg/runtime/schema"
27+
"k8s.io/klog/v2"
2728
"sigs.k8s.io/controller-runtime/pkg/client"
2829
"sigs.k8s.io/controller-runtime/pkg/handler"
2930
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -63,23 +64,23 @@ func GetMachinePoolByName(ctx context.Context, c client.Client, namespace, name
6364
func MachinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind, log logr.Logger) handler.MapFunc {
6465
log = log.WithValues("machine-pool-to-infra-map-func", gvk.String())
6566
return func(o client.Object) []reconcile.Request {
66-
log := log.WithValues("namespace", o.GetNamespace(), "name", o.GetName())
6767
m, ok := o.(*expv1.MachinePool)
6868
if !ok {
69-
log.V(4).Info("not a machine pool")
69+
log.V(4).Info("Not a machine pool", "Object", klog.KObj(o))
7070
return nil
7171
}
72+
log := log.WithValues("MachinePool", klog.KObj(o))
7273

7374
gk := gvk.GroupKind()
7475
ref := m.Spec.Template.Spec.InfrastructureRef
7576
// Return early if the GroupKind doesn't match what we expect.
7677
infraGK := ref.GroupVersionKind().GroupKind()
7778
if gk != infraGK {
78-
log.V(4).Info("infra kind doesn't match filter group kind", "infrastructureGroupKind", infraGK.String())
79+
log.V(4).Info("Infra kind doesn't match filter group kind", "infrastructureGroupKind", infraGK.String())
7980
return nil
8081
}
8182

82-
log.V(4).Info("projecting object", "namespace", m.Namespace, "name", ref.Name)
83+
log.V(4).Info("Projecting object")
8384
return []reconcile.Request{
8485
{
8586
NamespacedName: client.ObjectKey{

internal/controllers/cluster/cluster_controller_phases.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func (r *Reconciler) reconcileKubeconfig(ctx context.Context, cluster *clusterv1
274274
case apierrors.IsNotFound(err):
275275
if err := kubeconfig.CreateSecret(ctx, r.Client, cluster); err != nil {
276276
if err == kubeconfig.ErrDependentCertificateNotFound {
277-
log.Info("could not find secret for cluster, requeuing", "secret", secret.ClusterCA)
277+
log.Info("Could not find secret for cluster, requeuing", "Secret", secret.ClusterCA)
278278
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
279279
}
280280
return ctrl.Result{}, err

internal/controllers/machine/machine_controller_node_labels.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
corev1 "k8s.io/api/core/v1"
2323
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
24+
"k8s.io/klog/v2"
2425
ctrl "sigs.k8s.io/controller-runtime"
2526
"sigs.k8s.io/controller-runtime/pkg/client"
2627

@@ -48,7 +49,7 @@ func (r *Reconciler) reconcileInterruptibleNodeLabel(ctx context.Context, cluste
4849
// Get interruptible instance status from the infrastructure provider.
4950
interruptible, _, err := unstructured.NestedBool(infra.Object, "status", "interruptible")
5051
if err != nil {
51-
log.V(1).Error(err, "Failed to get interruptible status from infrastructure provider", "machinename", machine.Name)
52+
log.V(1).Error(err, "Failed to get interruptible status from infrastructure provider", "Machine", klog.KObj(machine))
5253
return ctrl.Result{}, nil
5354
}
5455
if !interruptible {

internal/controllers/machine/machine_controller_phases.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, cluster *clusterv1.
232232
}
233233
m.Spec.Bootstrap.DataSecretName = pointer.StringPtr(secretName)
234234
if !m.Status.BootstrapReady {
235-
log.Info("Bootstrap provider generated data secret and reports status.ready", bootstrapConfig.GetKind(), klog.KObj(bootstrapConfig), "secret", klog.KRef(m.Namespace, secretName))
235+
log.Info("Bootstrap provider generated data secret and reports status.ready", bootstrapConfig.GetKind(), klog.KObj(bootstrapConfig), "Secret", klog.KRef(m.Namespace, secretName))
236236
}
237237
m.Status.BootstrapReady = true
238238
return ctrl.Result{}, nil

internal/controllers/machinedeployment/machinedeployment_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func (r *Reconciler) getMachineDeploymentsForMachineSet(ctx context.Context, ms
314314
log := ctrl.LoggerFrom(ctx)
315315

316316
if len(ms.Labels) == 0 {
317-
log.V(2).Info("No MachineDeployments found for MachineSet because it has no labels", "machineset", ms.Name)
317+
log.V(2).Info("No MachineDeployments found for MachineSet because it has no labels", "MachineSet", klog.KObj(ms))
318318
return nil
319319
}
320320

internal/controllers/machinedeployment/machinedeployment_sync.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
apirand "k8s.io/apimachinery/pkg/util/rand"
3030
"k8s.io/apimachinery/pkg/util/sets"
3131
"k8s.io/client-go/util/retry"
32+
"k8s.io/klog/v2"
3233
ctrl "sigs.k8s.io/controller-runtime"
3334
"sigs.k8s.io/controller-runtime/pkg/client"
3435
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -236,13 +237,13 @@ func (r *Reconciler) getNewMachineSet(ctx context.Context, d *clusterv1.MachineD
236237

237238
return nil, err
238239
case err != nil:
239-
log.Error(err, "Failed to create new machine set", "machineset", newMS.Name)
240+
log.Error(err, "Failed to create new MachineSet", "MachineSet", klog.KObj(&newMS))
240241
r.recorder.Eventf(d, corev1.EventTypeWarning, "FailedCreate", "Failed to create MachineSet %q: %v", newMS.Name, err)
241242
return nil, err
242243
}
243244

244245
if !alreadyExists {
245-
log.V(4).Info("Created new machine set", "machineset", createdMS.Name)
246+
log.V(4).Info("Created new MachineSet", "MachineSet", klog.KObj(createdMS))
246247
r.recorder.Eventf(d, corev1.EventTypeNormal, "SuccessfulCreate", "Created MachineSet %q", newMS.Name)
247248
}
248249

internal/controllers/machineset/machineset_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ func (r *Reconciler) updateStatus(ctx context.Context, cluster *clusterv1.Cluste
660660
templateLabel := labels.Set(ms.Spec.Template.Labels).AsSelectorPreValidated()
661661

662662
for _, machine := range filteredMachines {
663-
log = log.WithValues("machine", klog.KObj(machine))
663+
log = log.WithValues("Machine", klog.KObj(machine))
664664

665665
if templateLabel.Matches(labels.Set(machine.Labels)) {
666666
fullyLabeledReplicasCount++

0 commit comments

Comments
 (0)