@@ -65,7 +65,10 @@ const (
6565 podDeletionPreventionFinalizer = "keep-from-vanishing"
6666)
6767
68- var maxRevivals = 3
68+ var (
69+ maxRevivals = 3
70+ terminationConditionReasons = []string {"DeletionByPodGC" , "DeletionByGCPControllerManager" }
71+ )
6972
7073func newFakeConfigAgent (t * testing.T , maxConcurrency int , queueCapacities map [string ]int ) * fca {
7174 presubmits := []config.Presubmit {
@@ -104,11 +107,12 @@ func newFakeConfigAgent(t *testing.T, maxConcurrency int, queueCapacities map[st
104107 MaxConcurrency : maxConcurrency ,
105108 MaxGoroutines : 20 ,
106109 },
107- JobQueueCapacities : queueCapacities ,
108- PodPendingTimeout : & metav1.Duration {Duration : podPendingTimeout },
109- PodRunningTimeout : & metav1.Duration {Duration : podRunningTimeout },
110- PodUnscheduledTimeout : & metav1.Duration {Duration : podUnscheduledTimeout },
111- MaxRevivals : & maxRevivals ,
110+ JobQueueCapacities : queueCapacities ,
111+ PodPendingTimeout : & metav1.Duration {Duration : podPendingTimeout },
112+ PodRunningTimeout : & metav1.Duration {Duration : podRunningTimeout },
113+ PodUnscheduledTimeout : & metav1.Duration {Duration : podUnscheduledTimeout },
114+ MaxRevivals : & maxRevivals ,
115+ TerminationConditionReasons : terminationConditionReasons ,
112116 },
113117 },
114118 JobConfig : config.JobConfig {
@@ -1246,8 +1250,72 @@ func TestSyncPendingJob(t *testing.T) {
12461250 },
12471251 },
12481252 },
1253+ ExpectedComplete : false ,
1254+ ExpectedState : prowapi .PendingState ,
1255+ ExpectedNumPods : 0 ,
1256+ },
1257+ {
1258+ Name : "delete terminated pod and remove its k8sreporter finalizer" ,
1259+ PJ : prowapi.ProwJob {
1260+ ObjectMeta : metav1.ObjectMeta {
1261+ Name : "boop-42" ,
1262+ Namespace : "prowjobs" ,
1263+ },
1264+ Spec : prowapi.ProwJobSpec {
1265+ PodSpec : & v1.PodSpec {Containers : []v1.Container {{Name : "test-name" , Env : []v1.EnvVar {}}}},
1266+ },
1267+ Status : prowapi.ProwJobStatus {
1268+ State : prowapi .PendingState ,
1269+ PodName : "boop-42" ,
1270+ },
1271+ },
1272+ Pods : []v1.Pod {
1273+ {
1274+ ObjectMeta : metav1.ObjectMeta {
1275+ Name : "boop-42" ,
1276+ Namespace : "pods" ,
1277+ Finalizers : []string {"prow.x-k8s.io/gcsk8sreporter" },
1278+ },
1279+ Status : v1.PodStatus {
1280+ Phase : v1 .PodFailed ,
1281+ Reason : Terminated ,
1282+ },
1283+ },
1284+ },
1285+ ExpectedComplete : false ,
1286+ ExpectedState : prowapi .PendingState ,
1287+ ExpectedNumPods : 0 ,
1288+ },
1289+ {
1290+ Name : "don't delete terminated pod w/ error_on_termination, complete PJ instead" ,
1291+ PJ : prowapi.ProwJob {
1292+ ObjectMeta : metav1.ObjectMeta {
1293+ Name : "boop-42" ,
1294+ Namespace : "prowjobs" ,
1295+ },
1296+ Spec : prowapi.ProwJobSpec {
1297+ ErrorOnTermination : true ,
1298+ PodSpec : & v1.PodSpec {Containers : []v1.Container {{Name : "test-name" , Env : []v1.EnvVar {}}}},
1299+ },
1300+ Status : prowapi.ProwJobStatus {
1301+ State : prowapi .PendingState ,
1302+ PodName : "boop-42" ,
1303+ },
1304+ },
1305+ Pods : []v1.Pod {
1306+ {
1307+ ObjectMeta : metav1.ObjectMeta {
1308+ Name : "boop-42" ,
1309+ Namespace : "pods" ,
1310+ },
1311+ Status : v1.PodStatus {
1312+ Phase : v1 .PodFailed ,
1313+ Reason : Terminated ,
1314+ },
1315+ },
1316+ },
12491317 ExpectedComplete : true ,
1250- ExpectedState : prowapi .FailureState ,
1318+ ExpectedState : prowapi .ErrorState ,
12511319 ExpectedNumPods : 1 ,
12521320 ExpectedURL : "boop-42/error" ,
12531321 },
0 commit comments