structured-logging: replace KObjs with KObjSlice for logging

This commit is contained in:
Harsha Narayana
2022-06-23 20:35:53 +05:30
parent d2cea9475b
commit c3cbc443ef
6 changed files with 20 additions and 22 deletions

View File

@@ -235,10 +235,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
@@ -806,7 +804,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
}