diff --git a/pkg/registry/core/pod/strategy.go b/pkg/registry/core/pod/strategy.go index 4350ad8cf6f..0f6376fb2d1 100644 --- a/pkg/registry/core/pod/strategy.go +++ b/pkg/registry/core/pod/strategy.go @@ -192,11 +192,14 @@ func NodeNameTriggerFunc(obj runtime.Object) []storage.MatchValue { // PodToSelectableFields returns a field set that represents the object // TODO: fields are not labels, and the validation rules for them do not apply. func PodToSelectableFields(pod *api.Pod) fields.Set { - podSpecificFieldsSet := fields.Set{ - "spec.nodeName": pod.Spec.NodeName, - "spec.restartPolicy": string(pod.Spec.RestartPolicy), - "status.phase": string(pod.Status.Phase), - } + // The purpose of allocation with a given number of elements is to reduce + // amount of allocations needed to create the fields.Set. If you add any + // field here or the number of object-meta related fields changes, this should + // be adjusted. + podSpecificFieldsSet := make(fields.Set, 5) + podSpecificFieldsSet["spec.nodeName"] = pod.Spec.NodeName + podSpecificFieldsSet["spec.restartPolicy"] = string(pod.Spec.RestartPolicy) + podSpecificFieldsSet["status.phase"] = string(pod.Status.Phase) return generic.AddObjectMetaFieldsSet(podSpecificFieldsSet, &pod.ObjectMeta, true) }