@@ -50,6 +50,28 @@ func prefixedName(namePrefix string, name string) string {
50
50
return fmt .Sprintf ("%s-%s" , namePrefix , name )
51
51
}
52
52
53
+ type podTerminationContainerStatus struct {
54
+ exitCode int32
55
+ reason string
56
+ }
57
+
58
+ func expectPodTerminationContainerStatuses (statuses []v1.ContainerStatus , to map [string ]podTerminationContainerStatus ) {
59
+ ginkgo .GinkgoHelper ()
60
+
61
+ if len (statuses ) != len (to ) {
62
+ ginkgo .Fail (fmt .Sprintf ("mismatched lengths in pod termination container statuses. got %d, expected %d" , len (statuses ), len (to )))
63
+ }
64
+ for _ , status := range statuses {
65
+ expected , ok := to [status .Name ]
66
+ if ! ok {
67
+ ginkgo .Fail (fmt .Sprintf ("container %q not found in expected pod termination container statuses" , status .Name ))
68
+ }
69
+ gomega .Expect (status .State .Terminated ).NotTo (gomega .BeNil ())
70
+ gomega .Expect (status .State .Terminated .ExitCode ).To (gomega .Equal (expected .exitCode ))
71
+ gomega .Expect (status .State .Terminated .Reason ).To (gomega .Equal (expected .reason ))
72
+ }
73
+ }
74
+
53
75
var _ = SIGDescribe (framework .WithNodeConformance (), "Containers Lifecycle" , func () {
54
76
f := framework .NewDefaultFramework ("containers-lifecycle-test" )
55
77
addAfterEachForCleaningUpPods (f )
@@ -3115,6 +3137,12 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
3115
3137
pod , err = client .Get (context .TODO (), pod .Name , metav1.GetOptions {})
3116
3138
framework .ExpectNoError (err )
3117
3139
3140
+ expectPodTerminationContainerStatuses (pod .Status .InitContainerStatuses , map [string ]podTerminationContainerStatus {
3141
+ restartableInit1 : {exitCode : int32 (0 ), reason : "Completed" },
3142
+ restartableInit2 : {exitCode : int32 (0 ), reason : "Completed" },
3143
+ restartableInit3 : {exitCode : int32 (0 ), reason : "Completed" },
3144
+ })
3145
+
3118
3146
results := parseOutput (context .TODO (), f , pod )
3119
3147
3120
3148
ginkgo .By ("Analyzing results" )
@@ -3221,6 +3249,13 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
3221
3249
pod , err = client .Get (context .TODO (), pod .Name , metav1.GetOptions {})
3222
3250
framework .ExpectNoError (err )
3223
3251
3252
+ // all restartable init containers are sigkilled with exit code 137
3253
+ expectPodTerminationContainerStatuses (pod .Status .InitContainerStatuses , map [string ]podTerminationContainerStatus {
3254
+ restartableInit1 : {exitCode : int32 (137 ), reason : "Error" },
3255
+ restartableInit2 : {exitCode : int32 (137 ), reason : "Error" },
3256
+ restartableInit3 : {exitCode : int32 (137 ), reason : "Error" },
3257
+ })
3258
+
3224
3259
results := parseOutput (context .TODO (), f , pod )
3225
3260
3226
3261
ginkgo .By ("Analyzing results" )
@@ -3352,6 +3387,12 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
3352
3387
pod , err = client .Get (context .TODO (), pod .Name , metav1.GetOptions {})
3353
3388
framework .ExpectNoError (err )
3354
3389
3390
+ expectPodTerminationContainerStatuses (pod .Status .InitContainerStatuses , map [string ]podTerminationContainerStatus {
3391
+ restartableInit1 : {exitCode : int32 (0 ), reason : "Completed" },
3392
+ restartableInit2 : {exitCode : int32 (0 ), reason : "Completed" },
3393
+ restartableInit3 : {exitCode : int32 (0 ), reason : "Completed" },
3394
+ })
3395
+
3355
3396
results := parseOutput (context .TODO (), f , pod )
3356
3397
3357
3398
ginkgo .By ("Analyzing results" )
0 commit comments