@@ -1171,6 +1171,17 @@ func TestComputePodActions(t *testing.T) {
1171
1171
ContainersToStart : []int {1 },
1172
1172
},
1173
1173
},
1174
+ "Restart the container if the container is in created state" : {
1175
+ mutatePodFn : func (pod * v1.Pod ) { pod .Spec .RestartPolicy = v1 .RestartPolicyNever },
1176
+ mutateStatusFn : func (status * kubecontainer.PodStatus ) {
1177
+ status .ContainerStatuses [1 ].State = kubecontainer .ContainerStateCreated
1178
+ },
1179
+ actions : podActions {
1180
+ SandboxID : baseStatus .SandboxStatuses [0 ].Id ,
1181
+ ContainersToKill : map [kubecontainer.ContainerID ]containerToKillInfo {},
1182
+ ContainersToStart : []int {1 },
1183
+ },
1184
+ },
1174
1185
} {
1175
1186
pod , status := makeBasePodAndStatus ()
1176
1187
if test .mutatePodFn != nil {
@@ -1545,12 +1556,17 @@ func TestComputePodActionsWithRestartableInitContainers(t *testing.T) {
1545
1556
ContainersToKill : getKillMapWithInitContainers (basePod , baseStatus , []int {}),
1546
1557
},
1547
1558
},
1548
- "initialization in progress; do nothing " : {
1559
+ "an init container is stuck in the created state; restart it " : {
1549
1560
mutatePodFn : func (pod * v1.Pod ) { pod .Spec .RestartPolicy = v1 .RestartPolicyAlways },
1550
1561
mutateStatusFn : func (pod * v1.Pod , status * kubecontainer.PodStatus ) {
1551
1562
status .ContainerStatuses [2 ].State = kubecontainer .ContainerStateCreated
1552
1563
},
1553
- actions : noAction ,
1564
+ actions : podActions {
1565
+ SandboxID : baseStatus .SandboxStatuses [0 ].Id ,
1566
+ InitContainersToStart : []int {2 },
1567
+ ContainersToStart : []int {},
1568
+ ContainersToKill : getKillMapWithInitContainers (basePod , baseStatus , []int {}),
1569
+ },
1554
1570
},
1555
1571
"restartable init container has started; start the next" : {
1556
1572
mutatePodFn : func (pod * v1.Pod ) { pod .Spec .RestartPolicy = v1 .RestartPolicyAlways },
0 commit comments