mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
test: Verify that nodes do not transition to Failed while ready
Signed-off-by: David Porter <david@porter.me>
This commit is contained in:
parent
c70f1955c4
commit
d6cd51e5c0
@ -30,6 +30,7 @@ import (
|
|||||||
|
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
|
"k8s.io/kubectl/pkg/util/podutils"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
@ -128,6 +129,11 @@ var _ = SIGDescribe("GracefulNodeShutdown [Serial] [NodeFeature:GracefulNodeShut
|
|||||||
framework.ExpectEqual(len(list.Items), len(pods), "the number of pods is not as expected")
|
framework.ExpectEqual(len(list.Items), len(pods), "the number of pods is not as expected")
|
||||||
|
|
||||||
for _, pod := range list.Items {
|
for _, pod := range list.Items {
|
||||||
|
if isPodStatusAffectedByIssue108594(&pod) {
|
||||||
|
framework.Logf("Detected invalid pod state for pod %q: pod status: %+v", pod.Name, pod.Status)
|
||||||
|
framework.Failf("failing test due to detecting invalid pod status")
|
||||||
|
}
|
||||||
|
|
||||||
if kubelettypes.IsCriticalPod(&pod) {
|
if kubelettypes.IsCriticalPod(&pod) {
|
||||||
if isPodShutdown(&pod) {
|
if isPodShutdown(&pod) {
|
||||||
framework.Logf("Expecting critical pod to be running, but it's not currently. Pod: %q, Pod Status %+v", pod.Name, pod.Status)
|
framework.Logf("Expecting critical pod to be running, but it's not currently. Pod: %q, Pod Status %+v", pod.Name, pod.Status)
|
||||||
@ -155,6 +161,10 @@ var _ = SIGDescribe("GracefulNodeShutdown [Serial] [NodeFeature:GracefulNodeShut
|
|||||||
framework.ExpectEqual(len(list.Items), len(pods), "the number of pods is not as expected")
|
framework.ExpectEqual(len(list.Items), len(pods), "the number of pods is not as expected")
|
||||||
|
|
||||||
for _, pod := range list.Items {
|
for _, pod := range list.Items {
|
||||||
|
if isPodStatusAffectedByIssue108594(&pod) {
|
||||||
|
framework.Logf("Detected invalid pod state for pod %q: pod status: %+v", pod.Name, pod.Status)
|
||||||
|
framework.Failf("failing test due to detecting invalid pod status")
|
||||||
|
}
|
||||||
if !isPodShutdown(&pod) {
|
if !isPodShutdown(&pod) {
|
||||||
framework.Logf("Expecting pod to be shutdown, but it's not currently: Pod: %q, Pod Status %+v", pod.Name, pod.Status)
|
framework.Logf("Expecting pod to be shutdown, but it's not currently: Pod: %q, Pod Status %+v", pod.Name, pod.Status)
|
||||||
return fmt.Errorf("pod should be shutdown, phase: %s", pod.Status.Phase)
|
return fmt.Errorf("pod should be shutdown, phase: %s", pod.Status.Phase)
|
||||||
@ -541,3 +551,8 @@ func isPodShutdown(pod *v1.Pod) bool {
|
|||||||
|
|
||||||
return pod.Status.Message == podShutdownMessage && pod.Status.Reason == podShutdownReason && hasContainersNotReadyCondition && pod.Status.Phase == v1.PodFailed
|
return pod.Status.Message == podShutdownMessage && pod.Status.Reason == podShutdownReason && hasContainersNotReadyCondition && pod.Status.Phase == v1.PodFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pods should never report failed phase and have ready condition = true (https://github.com/kubernetes/kubernetes/issues/108594)
|
||||||
|
func isPodStatusAffectedByIssue108594(pod *v1.Pod) bool {
|
||||||
|
return pod.Status.Phase == v1.PodFailed && podutils.IsPodReady(pod)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user