mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #22861 from ncdc/fix-rkt-pod-ids-order
Fix rkt GetPods() order
This commit is contained in:
commit
f7ec38ecba
@ -998,6 +998,7 @@ func (r *Runtime) GetPods(all bool) ([]*kubecontainer.Pod, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pods := make(map[types.UID]*kubecontainer.Pod)
|
pods := make(map[types.UID]*kubecontainer.Pod)
|
||||||
|
var podIDs []types.UID
|
||||||
for _, pod := range listResp.Pods {
|
for _, pod := range listResp.Pods {
|
||||||
pod, err := r.convertRktPod(pod)
|
pod, err := r.convertRktPod(pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1009,16 +1010,17 @@ func (r *Runtime) GetPods(all bool) ([]*kubecontainer.Pod, error) {
|
|||||||
oldPod, found := pods[pod.ID]
|
oldPod, found := pods[pod.ID]
|
||||||
if !found {
|
if !found {
|
||||||
pods[pod.ID] = pod
|
pods[pod.ID] = pod
|
||||||
|
podIDs = append(podIDs, pod.ID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
oldPod.Containers = append(oldPod.Containers, pod.Containers...)
|
oldPod.Containers = append(oldPod.Containers, pod.Containers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert map to list.
|
// Convert map to list, using the consistent order from the podIDs array.
|
||||||
var result []*kubecontainer.Pod
|
var result []*kubecontainer.Pod
|
||||||
for _, p := range pods {
|
for _, id := range podIDs {
|
||||||
result = append(result, p)
|
result = append(result, pods[id])
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user