Add pod disruption conditions for kubelet initiated failures
This commit is contained in:
@@ -668,9 +668,12 @@ func TestStalePodDisruption(t *testing.T) {
|
||||
|
||||
cases := map[string]struct {
|
||||
deletePod bool
|
||||
podPhase v1.PodPhase
|
||||
reason string
|
||||
wantConditions []v1.PodCondition
|
||||
}{
|
||||
"stale-condition": {
|
||||
podPhase: v1.PodRunning,
|
||||
wantConditions: []v1.PodCondition{
|
||||
{
|
||||
Type: v1.AlphaNoCompatGuaranteeDisruptionTarget,
|
||||
@@ -679,6 +682,7 @@ func TestStalePodDisruption(t *testing.T) {
|
||||
},
|
||||
},
|
||||
"deleted-pod": {
|
||||
podPhase: v1.PodRunning,
|
||||
deletePod: true,
|
||||
wantConditions: []v1.PodCondition{
|
||||
{
|
||||
@@ -687,6 +691,26 @@ func TestStalePodDisruption(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
"disruption-condition-by-kubelet": {
|
||||
podPhase: v1.PodFailed,
|
||||
reason: v1.AlphaNoCompatGuaranteePodReasonTerminationByKubelet,
|
||||
wantConditions: []v1.PodCondition{
|
||||
{
|
||||
Type: v1.AlphaNoCompatGuaranteeDisruptionTarget,
|
||||
Status: v1.ConditionTrue,
|
||||
Reason: v1.AlphaNoCompatGuaranteePodReasonTerminationByKubelet,
|
||||
},
|
||||
},
|
||||
},
|
||||
"disruption-condition-on-failed-pod": {
|
||||
podPhase: v1.PodFailed,
|
||||
wantConditions: []v1.PodCondition{
|
||||
{
|
||||
Type: v1.AlphaNoCompatGuaranteeDisruptionTarget,
|
||||
Status: v1.ConditionTrue,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range cases {
|
||||
@@ -702,10 +726,11 @@ func TestStalePodDisruption(t *testing.T) {
|
||||
t.Fatalf("Failed creating pod: %v", err)
|
||||
}
|
||||
|
||||
pod.Status.Phase = v1.PodRunning
|
||||
pod.Status.Phase = tc.podPhase
|
||||
pod.Status.Conditions = append(pod.Status.Conditions, v1.PodCondition{
|
||||
Type: v1.AlphaNoCompatGuaranteeDisruptionTarget,
|
||||
Status: v1.ConditionTrue,
|
||||
Reason: tc.reason,
|
||||
LastTransitionTime: metav1.Now(),
|
||||
})
|
||||
pod, err = clientSet.CoreV1().Pods(nsName).UpdateStatus(ctx, pod, metav1.UpdateOptions{})
|
||||
|
Reference in New Issue
Block a user