mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
fix tests; convert IsPodActive to operate on *Pod
This commit is contained in:
parent
331083727f
commit
594234d61c
@ -59,7 +59,7 @@ func (m *PodControllerRefManager) Classify(pods []*api.Pod) (
|
|||||||
controlledDoesNotMatch []*api.Pod) {
|
controlledDoesNotMatch []*api.Pod) {
|
||||||
for i := range pods {
|
for i := range pods {
|
||||||
pod := pods[i]
|
pod := pods[i]
|
||||||
if !IsPodActive(*pod) {
|
if !IsPodActive(pod) {
|
||||||
glog.V(4).Infof("Ignoring inactive pod %v/%v in state %v, deletion time %v",
|
glog.V(4).Infof("Ignoring inactive pod %v/%v in state %v, deletion time %v",
|
||||||
pod.Namespace, pod.Name, pod.Status.Phase, pod.DeletionTimestamp)
|
pod.Namespace, pod.Name, pod.Status.Phase, pod.DeletionTimestamp)
|
||||||
continue
|
continue
|
||||||
|
@ -686,7 +686,7 @@ func maxContainerRestarts(pod *api.Pod) int {
|
|||||||
func FilterActivePods(pods []*api.Pod) []*api.Pod {
|
func FilterActivePods(pods []*api.Pod) []*api.Pod {
|
||||||
var result []*api.Pod
|
var result []*api.Pod
|
||||||
for _, p := range pods {
|
for _, p := range pods {
|
||||||
if IsPodActive(*p) {
|
if IsPodActive(p) {
|
||||||
result = append(result, p)
|
result = append(result, p)
|
||||||
} else {
|
} else {
|
||||||
glog.V(4).Infof("Ignoring inactive pod %v/%v in state %v, deletion time %v",
|
glog.V(4).Infof("Ignoring inactive pod %v/%v in state %v, deletion time %v",
|
||||||
@ -696,7 +696,7 @@ func FilterActivePods(pods []*api.Pod) []*api.Pod {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsPodActive(p api.Pod) bool {
|
func IsPodActive(p *api.Pod) bool {
|
||||||
return api.PodSucceeded != p.Status.Phase &&
|
return api.PodSucceeded != p.Status.Phase &&
|
||||||
api.PodFailed != p.Status.Phase &&
|
api.PodFailed != p.Status.Phase &&
|
||||||
p.DeletionTimestamp == nil
|
p.DeletionTimestamp == nil
|
||||||
|
@ -287,7 +287,11 @@ func TestActivePodFiltering(t *testing.T) {
|
|||||||
expectedNames.Insert(pod.Name)
|
expectedNames.Insert(pod.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
got := FilterActivePods(podList.Items)
|
var podPointers []*api.Pod
|
||||||
|
for i := range podList.Items {
|
||||||
|
podPointers = append(podPointers, &podList.Items[i])
|
||||||
|
}
|
||||||
|
got := FilterActivePods(podPointers)
|
||||||
gotNames := sets.NewString()
|
gotNames := sets.NewString()
|
||||||
for _, pod := range got {
|
for _, pod := range got {
|
||||||
gotNames.Insert(pod.Name)
|
gotNames.Insert(pod.Name)
|
||||||
|
@ -633,7 +633,7 @@ func countAvailablePods(pods []api.Pod, minReadySeconds int32) int32 {
|
|||||||
|
|
||||||
// IsPodAvailable return true if the pod is available.
|
// IsPodAvailable return true if the pod is available.
|
||||||
func IsPodAvailable(pod *api.Pod, minReadySeconds int32, now time.Time) bool {
|
func IsPodAvailable(pod *api.Pod, minReadySeconds int32, now time.Time) bool {
|
||||||
if !controller.IsPodActive(*pod) {
|
if !controller.IsPodActive(pod) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// Check if we've passed minReadySeconds since LastTransitionTime
|
// Check if we've passed minReadySeconds since LastTransitionTime
|
||||||
|
@ -3166,7 +3166,7 @@ func waitForPodsInactive(ps *PodStore, interval, timeout time.Duration) error {
|
|||||||
return wait.PollImmediate(interval, timeout, func() (bool, error) {
|
return wait.PollImmediate(interval, timeout, func() (bool, error) {
|
||||||
pods := ps.List()
|
pods := ps.List()
|
||||||
for _, pod := range pods {
|
for _, pod := range pods {
|
||||||
if controller.IsPodActive(*pod) {
|
if controller.IsPodActive(pod) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user