mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #22033 from yifan-gu/rkt_get_status
Auto commit by PR queue bot
This commit is contained in:
commit
357a9d1fdf
@ -472,3 +472,12 @@ func ParsePodFullName(podFullName string) (string, string, error) {
|
||||
// Option is a functional option type for Runtime, useful for
|
||||
// completely optional settings.
|
||||
type Option func(Runtime)
|
||||
|
||||
// Sort the container statuses by creation time.
|
||||
type SortContainerStatusesByCreationTime []*ContainerStatus
|
||||
|
||||
func (s SortContainerStatusesByCreationTime) Len() int { return len(s) }
|
||||
func (s SortContainerStatusesByCreationTime) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
func (s SortContainerStatusesByCreationTime) Less(i, j int) bool {
|
||||
return s[i].CreatedAt.Before(s[j].CreatedAt)
|
||||
}
|
||||
|
@ -3312,6 +3312,9 @@ func (kl *Kubelet) convertStatusToAPIStatus(pod *api.Pod, podStatus *kubecontain
|
||||
return status
|
||||
}
|
||||
|
||||
// Make the latest container status comes first.
|
||||
sort.Sort(sort.Reverse(kubecontainer.SortContainerStatusesByCreationTime(podStatus.ContainerStatuses)))
|
||||
|
||||
statuses := make(map[string]*api.ContainerStatus, len(pod.Spec.Containers))
|
||||
// Create a map of expected containers based on the pod spec.
|
||||
expectedContainers := make(map[string]api.Container)
|
||||
|
@ -1483,9 +1483,3 @@ func (r *Runtime) GetPodStatus(uid types.UID, name, namespace string) (*kubecont
|
||||
|
||||
return podStatus, nil
|
||||
}
|
||||
|
||||
type sortByRestartCount []*kubecontainer.ContainerStatus
|
||||
|
||||
func (s sortByRestartCount) Len() int { return len(s) }
|
||||
func (s sortByRestartCount) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
func (s sortByRestartCount) Less(i, j int) bool { return s[i].RestartCount < s[j].RestartCount }
|
||||
|
Loading…
Reference in New Issue
Block a user