mirror of https://github.com/k3s-io/k3s
eviction test ensures failed pods are evicted
parent
51d75a7b1e
commit
a5df208866
|
@ -143,7 +143,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)
|
||||
return lifecycle.PodAdmitResult{
|
||||
Admit: false,
|
||||
Reason: reason,
|
||||
Reason: Reason,
|
||||
Message: fmt.Sprintf(message, m.nodeConditions),
|
||||
}
|
||||
}
|
||||
|
@ -569,10 +569,10 @@ func (m *managerImpl) evictPod(pod *v1.Pod, gracePeriodOverride int64, evictMsg
|
|||
status := v1.PodStatus{
|
||||
Phase: v1.PodFailed,
|
||||
Message: evictMsg,
|
||||
Reason: reason,
|
||||
Reason: Reason,
|
||||
}
|
||||
// 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.
|
||||
err := m.killPodFunc(pod, status, &gracePeriodOverride)
|
||||
if err != nil {
|
||||
|
|
|
@ -38,8 +38,8 @@ import (
|
|||
|
||||
const (
|
||||
unsupportedEvictionSignal = "unsupported eviction signal %v"
|
||||
// the reason reported back in status.
|
||||
reason = "Evicted"
|
||||
// Reason is the reason reported back in status.
|
||||
Reason = "Evicted"
|
||||
// the message associated with the reason.
|
||||
message = "The node was low on resource: %v. "
|
||||
// additional information for containers exceeding requests
|
||||
|
@ -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.
|
||||
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.
|
||||
|
|
|
@ -128,6 +128,7 @@ go_test(
|
|||
"//pkg/kubelet/cm/cpumanager:go_default_library",
|
||||
"//pkg/kubelet/cm/cpuset:go_default_library",
|
||||
"//pkg/kubelet/container:go_default_library",
|
||||
"//pkg/kubelet/eviction:go_default_library",
|
||||
"//pkg/kubelet/images:go_default_library",
|
||||
"//pkg/kubelet/kubeletconfig:go_default_library",
|
||||
"//pkg/kubelet/kubeletconfig/status:go_default_library",
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
|
||||
stats "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
|
||||
"k8s.io/kubernetes/pkg/kubelet/eviction"
|
||||
kubeletmetrics "k8s.io/kubernetes/pkg/kubelet/metrics"
|
||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
|
@ -505,6 +506,8 @@ func verifyEvictionOrdering(f *framework.Framework, testSpecs []podEvictSpec) er
|
|||
}
|
||||
}
|
||||
Expect(priorityPod).NotTo(BeNil())
|
||||
Expect(priorityPod.Status.Phase).NotTo(Equal(v1.PodSucceeded),
|
||||
fmt.Sprintf("pod: %s succeeded unexpectedly", priorityPod.Name))
|
||||
|
||||
// Check eviction ordering.
|
||||
// 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
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
if priorityPodSpec.evictionPriority == 0 {
|
||||
Expect(priorityPod.Status.Phase).NotTo(Equal(v1.PodFailed),
|
||||
|
|
Loading…
Reference in New Issue