@@ -115,7 +115,7 @@ var _ = Describe("Drain Controller", Ordered, func() {
115115 Context ("when there is only one node" , func () {
116116
117117 It ("should drain single node on drain require" , func (ctx context.Context ) {
118- node , nodeState := createNode (ctx , "node1" )
118+ node , nodeState := createNode (ctx , "node1" , false )
119119
120120 simulateDaemonSetAnnotation (node , constants .DrainRequired )
121121
@@ -129,7 +129,7 @@ var _ = Describe("Drain Controller", Ordered, func() {
129129 })
130130
131131 It ("should not drain on reboot for single node" , func (ctx context.Context ) {
132- node , nodeState := createNode (ctx , "node1" )
132+ node , nodeState := createNode (ctx , "node1" , false )
133133
134134 simulateDaemonSetAnnotation (node , constants .RebootRequired )
135135
@@ -142,8 +142,8 @@ var _ = Describe("Drain Controller", Ordered, func() {
142142 })
143143
144144 It ("should drain on reboot for multiple node" , func (ctx context.Context ) {
145- node , nodeState := createNode (ctx , "node1" )
146- createNode (ctx , "node2" )
145+ node , nodeState := createNode (ctx , "node1" , false )
146+ createNode (ctx , "node2" , false )
147147
148148 simulateDaemonSetAnnotation (node , constants .RebootRequired )
149149
@@ -159,9 +159,9 @@ var _ = Describe("Drain Controller", Ordered, func() {
159159 Context ("when there are multiple nodes" , func () {
160160
161161 It ("should drain nodes serially with default pool selector" , func (ctx context.Context ) {
162- node1 , nodeState1 := createNode (ctx , "node1" )
163- node2 , nodeState2 := createNode (ctx , "node2" )
164- node3 , nodeState3 := createNode (ctx , "node3" )
162+ node1 , nodeState1 := createNode (ctx , "node1" , false )
163+ node2 , nodeState2 := createNode (ctx , "node2" , false )
164+ node3 , nodeState3 := createNode (ctx , "node3" , false )
165165
166166 // Two nodes require to drain at the same time
167167 simulateDaemonSetAnnotation (node1 , constants .DrainRequired )
@@ -199,9 +199,9 @@ var _ = Describe("Drain Controller", Ordered, func() {
199199 })
200200
201201 It ("should drain nodes in parallel with a custom pool selector" , func (ctx context.Context ) {
202- node1 , nodeState1 := createNode (ctx , "node1" )
203- node2 , nodeState2 := createNode (ctx , "node2" )
204- node3 , nodeState3 := createNode (ctx , "node3" )
202+ node1 , nodeState1 := createNode (ctx , "node1" , false )
203+ node2 , nodeState2 := createNode (ctx , "node2" , false )
204+ node3 , nodeState3 := createNode (ctx , "node3" , false )
205205
206206 maxun := intstr .Parse ("2" )
207207 poolConfig := & sriovnetworkv1.SriovNetworkPoolConfig {}
@@ -250,9 +250,9 @@ var _ = Describe("Drain Controller", Ordered, func() {
250250 })
251251
252252 It ("should drain nodes in parallel with a custom pool selector and honor MaxUnavailable" , func (ctx context.Context ) {
253- node1 , nodeState1 := createNode (ctx , "node1" )
254- node2 , nodeState2 := createNode (ctx , "node2" )
255- node3 , nodeState3 := createNode (ctx , "node3" )
253+ node1 , nodeState1 := createNode (ctx , "node1" , false )
254+ node2 , nodeState2 := createNode (ctx , "node2" , false )
255+ node3 , nodeState3 := createNode (ctx , "node3" , false )
256256
257257 maxun := intstr .Parse ("2" )
258258 poolConfig := & sriovnetworkv1.SriovNetworkPoolConfig {}
@@ -275,9 +275,9 @@ var _ = Describe("Drain Controller", Ordered, func() {
275275 })
276276
277277 It ("should drain all nodes in parallel with a custom pool using nil in max unavailable" , func (ctx context.Context ) {
278- node1 , nodeState1 := createNode (ctx , "node1" )
279- node2 , nodeState2 := createNode (ctx , "node2" )
280- node3 , nodeState3 := createNode (ctx , "node3" )
278+ node1 , nodeState1 := createNode (ctx , "node1" , false )
279+ node2 , nodeState2 := createNode (ctx , "node2" , false )
280+ node3 , nodeState3 := createNode (ctx , "node3" , false )
281281
282282 poolConfig := & sriovnetworkv1.SriovNetworkPoolConfig {}
283283 poolConfig .SetNamespace (testNamespace )
@@ -303,7 +303,7 @@ var _ = Describe("Drain Controller", Ordered, func() {
303303 })
304304
305305 It ("should drain in parallel nodes from two different pools, one custom and one default" , func () {
306- node1 , nodeState1 := createNode (ctx , "node1" )
306+ node1 , nodeState1 := createNode (ctx , "node1" , false )
307307 node2 , nodeState2 := createNodeWithLabel (ctx , "node2" , "pool" )
308308 createPodOnNode (ctx , "test-node-2" , "node2" )
309309
@@ -326,7 +326,7 @@ var _ = Describe("Drain Controller", Ordered, func() {
326326 })
327327
328328 It ("should select all the nodes to drain in parallel when the selector is empty" , func () {
329- node1 , nodeState1 := createNode (ctx , "node3" )
329+ node1 , nodeState1 := createNode (ctx , "node3" , false )
330330 node2 , nodeState2 := createNodeWithLabel (ctx , "node4" , "pool" )
331331 createPodOnNode (ctx , "test-empty-1" , "node3" )
332332 createPodOnNode (ctx , "test-empty-2" , "node4" )
@@ -408,7 +408,7 @@ func simulateDaemonSetAnnotation(node *corev1.Node, drainAnnotationValue string)
408408 ToNot (HaveOccurred ())
409409}
410410
411- func createNode (ctx context.Context , nodeName string ) (* corev1.Node , * sriovnetworkv1.SriovNetworkNodeState ) {
411+ func createNode (ctx context.Context , nodeName string , useExternalDrainer bool ) (* corev1.Node , * sriovnetworkv1.SriovNetworkNodeState ) {
412412 node := corev1.Node {
413413 ObjectMeta : metav1.ObjectMeta {
414414 Name : nodeName ,
@@ -432,6 +432,10 @@ func createNode(ctx context.Context, nodeName string) (*corev1.Node, *sriovnetwo
432432 },
433433 }
434434
435+ if useExternalDrainer {
436+ nodeState .Annotations [constants .NodeStateExternalDrainerAnnotation ] = "true"
437+ }
438+
435439 Expect (k8sClient .Create (ctx , & node )).ToNot (HaveOccurred ())
436440 Expect (k8sClient .Create (ctx , & nodeState )).ToNot (HaveOccurred ())
437441
0 commit comments