Merge pull request #110747 from harshanarayana/cleanup/GIT-110737/logging-improvements

structured-logging: replace KObjs with KObjSlice for logging
This commit is contained in:
Kubernetes Prow Robot
2022-11-03 00:49:34 -07:00
committed by GitHub
6 changed files with 20 additions and 22 deletions

View File

@@ -231,10 +231,8 @@ func (rsc *ReplicaSetController) getReplicaSetsWithSameController(rs *apps.Repli
relatedRSs = append(relatedRSs, obj.(*apps.ReplicaSet))
}
// The if check is used to avoid the overhead for the KObjs call, see
// https://github.com/kubernetes/kubernetes/issues/106945.
if klogV := klog.V(2); klogV.Enabled() {
klogV.InfoS("Found related ReplicaSets", "replicaSet", klog.KObj(rs), "relatedReplicaSets", klog.KObjs(relatedRSs))
klogV.InfoS("Found related ReplicaSets", "replicaSet", klog.KObj(rs), "relatedReplicaSets", klog.KObjSlice(relatedRSs))
}
return relatedRSs
@@ -802,7 +800,7 @@ func (rsc *ReplicaSetController) getIndirectlyRelatedPods(rs *apps.ReplicaSet) (
relatedPods = append(relatedPods, pod)
}
}
klog.V(4).InfoS("Found related pods", "kind", rsc.Kind, "object", klog.KObj(rs), "pods", klog.KObjs(relatedPods))
klog.V(4).InfoS("Found related pods", "kind", rsc.Kind, "object", klog.KObj(rs), "pods", klog.KObjSlice(relatedPods))
return relatedPods, nil
}

View File

@@ -417,5 +417,5 @@ func (rc *reconciler) reportMultiAttachError(volumeToAttach cache.VolumeToAttach
}
// Log all pods for system admin
klog.InfoS("Multi-Attach error: volume is already used by pods", "pods", klog.KObjs(pods), "attachedTo", otherNodesStr, "volume", volumeToAttach)
klog.InfoS("Multi-Attach error: volume is already used by pods", "pods", klog.KObjSlice(pods), "attachedTo", otherNodesStr, "volume", volumeToAttach)
}