mirror of https://github.com/k3s-io/k3s
avoiding unnecessary loop to copy pods listed see #46433
adding comments stating that returned pods should be used as read-only objects fixing typo avoiding unnecessary loop to copy pods listed see #46433 fixing fmt avoiding unnecessary loop to copy pods listed see #46433pull/6/head
parent
a673d99731
commit
cc5977aaa0
|
@ -421,6 +421,8 @@ func (dc *DisruptionController) getPdbForPod(pod *v1.Pod) *policy.PodDisruptionB
|
||||||
return pdbs[0]
|
return pdbs[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function returns pods using the PodDisruptionBudget object.
|
||||||
|
// IMPORTANT NOTE : the returned pods should NOT be modified.
|
||||||
func (dc *DisruptionController) getPodsForPdb(pdb *policy.PodDisruptionBudget) ([]*v1.Pod, error) {
|
func (dc *DisruptionController) getPodsForPdb(pdb *policy.PodDisruptionBudget) ([]*v1.Pod, error) {
|
||||||
sel, err := metav1.LabelSelectorAsSelector(pdb.Spec.Selector)
|
sel, err := metav1.LabelSelectorAsSelector(pdb.Spec.Selector)
|
||||||
if sel.Empty() {
|
if sel.Empty() {
|
||||||
|
@ -433,12 +435,7 @@ func (dc *DisruptionController) getPodsForPdb(pdb *policy.PodDisruptionBudget) (
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []*v1.Pod{}, err
|
return []*v1.Pod{}, err
|
||||||
}
|
}
|
||||||
// TODO: Do we need to copy here?
|
return pods, nil
|
||||||
result := make([]*v1.Pod, 0, len(pods))
|
|
||||||
for i := range pods {
|
|
||||||
result = append(result, &(*pods[i]))
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *DisruptionController) worker() {
|
func (dc *DisruptionController) worker() {
|
||||||
|
|
Loading…
Reference in New Issue