@@ -98,6 +98,7 @@ var _ = BeforeEach(func() {
98
98
}
99
99
fakeClock .SetTime (time .Now ())
100
100
state .PodSchedulingDecisionSeconds .Reset ()
101
+ pscheduling .DefaultTerminationGracePeriod = nil
101
102
})
102
103
103
104
var _ = AfterSuite (func () {
@@ -220,6 +221,42 @@ var _ = Describe("Provisioning", func() {
220
221
Expect (len (nodes .Items )).To (Equal (1 ))
221
222
ExpectScheduled (ctx , env .Client , pod )
222
223
})
224
+ It ("should expect nodeclaim terminationGracePeriod to be the global value when the nodepool terminationGracePeriod is not set" , func () {
225
+ nodePool := test .NodePool ()
226
+ pscheduling .DefaultTerminationGracePeriod = & metav1.Duration {Duration : 98 * time .Hour }
227
+ ExpectApplied (ctx , env .Client , nodePool )
228
+ pod := test .UnschedulablePod ()
229
+ ExpectProvisioned (ctx , env .Client , cluster , cloudProvider , prov , pod )
230
+ ExpectScheduled (ctx , env .Client , pod )
231
+ nodeClaims := & v1.NodeClaimList {}
232
+ Expect (env .Client .List (ctx , nodeClaims )).To (Succeed ())
233
+ Expect (len (nodeClaims .Items )).To (Equal (1 ))
234
+ Expect (nodeClaims .Items [0 ].Spec .TerminationGracePeriod .Duration ).To (BeNumerically ("==" , 98 * time .Hour ))
235
+ })
236
+ It ("should expect nodeclaim terminationGracePeriod to be the nil when the nodepool terminationGracePeriod and global terminationGracePeriod is not set" , func () {
237
+ nodePool := test .NodePool ()
238
+ ExpectApplied (ctx , env .Client , nodePool )
239
+ pod := test .UnschedulablePod ()
240
+ ExpectProvisioned (ctx , env .Client , cluster , cloudProvider , prov , pod )
241
+ ExpectScheduled (ctx , env .Client , pod )
242
+ nodeClaims := & v1.NodeClaimList {}
243
+ Expect (env .Client .List (ctx , nodeClaims )).To (Succeed ())
244
+ Expect (len (nodeClaims .Items )).To (Equal (1 ))
245
+ Expect (nodeClaims .Items [0 ].Spec .TerminationGracePeriod ).To (BeNil ())
246
+ })
247
+ It ("should respect terminationGracePeriod value set on the nodePool over global terminationGracePeriod" , func () {
248
+ nodePool := test .NodePool ()
249
+ nodePool .Spec .Template .Spec .TerminationGracePeriod = & metav1.Duration {Duration : 223 * time .Hour }
250
+ pscheduling .DefaultTerminationGracePeriod = & metav1.Duration {Duration : 47 * time .Hour }
251
+ ExpectApplied (ctx , env .Client , nodePool )
252
+ pod := test .UnschedulablePod ()
253
+ ExpectProvisioned (ctx , env .Client , cluster , cloudProvider , prov , pod )
254
+ ExpectScheduled (ctx , env .Client , pod )
255
+ nodeClaims := & v1.NodeClaimList {}
256
+ Expect (env .Client .List (ctx , nodeClaims )).To (Succeed ())
257
+ Expect (len (nodeClaims .Items )).To (Equal (1 ))
258
+ Expect (nodeClaims .Items [0 ].Spec .TerminationGracePeriod .Duration ).To (BeNumerically ("==" , 223 * time .Hour ))
259
+ })
223
260
It ("should ignore NodePools that are deleting" , func () {
224
261
nodePool := test .NodePool ()
225
262
ExpectApplied (ctx , env .Client , nodePool )
0 commit comments