Unverified Commit 2accf11f authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #57849 from dashpole/eviction_test_event

Automatic merge from submit-queue (batch tested with PRs 63865, 57849, 63932, 63930, 63936). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Eviction Node e2e test checks for eviction reason **What this PR does / why we need it**: Currently, the eviction test simply ensures that pods are marked `Failed`. However, this could occur because of an OOM, rather than an eviction. To ensure that pods are actually being evicted, check for the Reason in the pod status to ensure it is evicted. **Release note**: ```release-note NONE ``` cc @kubernetes/sig-node-pr-reviews
parents 0519170e a5df2088
...@@ -156,7 +156,7 @@ func (m *managerImpl) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAd ...@@ -156,7 +156,7 @@ func (m *managerImpl) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAd
glog.Warningf("Failed to admit pod %s - node has conditions: %v", format.Pod(attrs.Pod), m.nodeConditions) glog.Warningf("Failed to admit pod %s - node has conditions: %v", format.Pod(attrs.Pod), m.nodeConditions)
return lifecycle.PodAdmitResult{ return lifecycle.PodAdmitResult{
Admit: false, Admit: false,
Reason: reason, Reason: Reason,
Message: fmt.Sprintf(message, m.nodeConditions), Message: fmt.Sprintf(message, m.nodeConditions),
} }
} }
...@@ -608,10 +608,10 @@ func (m *managerImpl) evictPod(pod *v1.Pod, gracePeriodOverride int64, evictMsg ...@@ -608,10 +608,10 @@ func (m *managerImpl) evictPod(pod *v1.Pod, gracePeriodOverride int64, evictMsg
status := v1.PodStatus{ status := v1.PodStatus{
Phase: v1.PodFailed, Phase: v1.PodFailed,
Message: evictMsg, Message: evictMsg,
Reason: reason, Reason: Reason,
} }
// record that we are evicting the pod // record that we are evicting the pod
m.recorder.Eventf(pod, v1.EventTypeWarning, reason, evictMsg) m.recorder.Eventf(pod, v1.EventTypeWarning, Reason, evictMsg)
// this is a blocking call and should only return when the pod and its containers are killed. // this is a blocking call and should only return when the pod and its containers are killed.
err := m.killPodFunc(pod, status, &gracePeriodOverride) err := m.killPodFunc(pod, status, &gracePeriodOverride)
if err != nil { if err != nil {
......
...@@ -38,8 +38,8 @@ import ( ...@@ -38,8 +38,8 @@ import (
const ( const (
unsupportedEvictionSignal = "unsupported eviction signal %v" unsupportedEvictionSignal = "unsupported eviction signal %v"
// the reason reported back in status. // Reason is the reason reported back in status.
reason = "Evicted" Reason = "Evicted"
// the message associated with the reason. // the message associated with the reason.
message = "The node was low on resource: %v. " message = "The node was low on resource: %v. "
// additional information for containers exceeding requests // additional information for containers exceeding requests
...@@ -1028,7 +1028,7 @@ func buildSignalToRankFunc(withImageFs bool) map[evictionapi.Signal]rankFunc { ...@@ -1028,7 +1028,7 @@ func buildSignalToRankFunc(withImageFs bool) map[evictionapi.Signal]rankFunc {
// PodIsEvicted returns true if the reported pod status is due to an eviction. // PodIsEvicted returns true if the reported pod status is due to an eviction.
func PodIsEvicted(podStatus v1.PodStatus) bool { func PodIsEvicted(podStatus v1.PodStatus) bool {
return podStatus.Phase == v1.PodFailed && podStatus.Reason == reason return podStatus.Phase == v1.PodFailed && podStatus.Reason == Reason
} }
// buildSignalToNodeReclaimFuncs returns reclaim functions associated with resources. // buildSignalToNodeReclaimFuncs returns reclaim functions associated with resources.
......
...@@ -128,6 +128,7 @@ go_test( ...@@ -128,6 +128,7 @@ go_test(
"//pkg/kubelet/cm/cpumanager:go_default_library", "//pkg/kubelet/cm/cpumanager:go_default_library",
"//pkg/kubelet/cm/cpuset:go_default_library", "//pkg/kubelet/cm/cpuset:go_default_library",
"//pkg/kubelet/container:go_default_library", "//pkg/kubelet/container:go_default_library",
"//pkg/kubelet/eviction:go_default_library",
"//pkg/kubelet/images:go_default_library", "//pkg/kubelet/images:go_default_library",
"//pkg/kubelet/kubeletconfig:go_default_library", "//pkg/kubelet/kubeletconfig:go_default_library",
"//pkg/kubelet/kubeletconfig/status:go_default_library", "//pkg/kubelet/kubeletconfig/status:go_default_library",
......
...@@ -29,6 +29,7 @@ import ( ...@@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig" "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
stats "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1" stats "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
"k8s.io/kubernetes/pkg/kubelet/eviction"
kubeletmetrics "k8s.io/kubernetes/pkg/kubelet/metrics" kubeletmetrics "k8s.io/kubernetes/pkg/kubelet/metrics"
kubetypes "k8s.io/kubernetes/pkg/kubelet/types" kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
...@@ -505,6 +506,8 @@ func verifyEvictionOrdering(f *framework.Framework, testSpecs []podEvictSpec) er ...@@ -505,6 +506,8 @@ func verifyEvictionOrdering(f *framework.Framework, testSpecs []podEvictSpec) er
} }
} }
Expect(priorityPod).NotTo(BeNil()) Expect(priorityPod).NotTo(BeNil())
Expect(priorityPod.Status.Phase).NotTo(Equal(v1.PodSucceeded),
fmt.Sprintf("pod: %s succeeded unexpectedly", priorityPod.Name))
// Check eviction ordering. // Check eviction ordering.
// Note: it is alright for a priority 1 and priority 2 pod (for example) to fail in the same round, // Note: it is alright for a priority 1 and priority 2 pod (for example) to fail in the same round,
...@@ -524,6 +527,11 @@ func verifyEvictionOrdering(f *framework.Framework, testSpecs []podEvictSpec) er ...@@ -524,6 +527,11 @@ func verifyEvictionOrdering(f *framework.Framework, testSpecs []podEvictSpec) er
} }
} }
if priorityPod.Status.Phase == v1.PodFailed {
Expect(priorityPod.Status.Reason, eviction.Reason, "pod %s failed; expected Status.Reason to be %s, but got %s",
priorityPod.Name, eviction.Reason, priorityPod.Status.Reason)
}
// EvictionPriority 0 pods should not fail // EvictionPriority 0 pods should not fail
if priorityPodSpec.evictionPriority == 0 { if priorityPodSpec.evictionPriority == 0 {
Expect(priorityPod.Status.Phase).NotTo(Equal(v1.PodFailed), Expect(priorityPod.Status.Phase).NotTo(Equal(v1.PodFailed),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment