@@ -131,7 +131,7 @@ var _ = Describe("Drain Controller", Ordered, func() {
131131 Context ("when there is only one node" , func () {
132132
133133 It ("should drain single node on drain require" , func (ctx context.Context ) {
134- node , nodeState := createNode (ctx , "node1" )
134+ node , nodeState := createNode (ctx , "node1" , false )
135135
136136 simulateDaemonSetAnnotation (node , constants .DrainRequired )
137137
@@ -145,7 +145,7 @@ var _ = Describe("Drain Controller", Ordered, func() {
145145 })
146146
147147 It ("should not drain on reboot for single node" , func (ctx context.Context ) {
148- node , nodeState := createNode (ctx , "node1" )
148+ node , nodeState := createNode (ctx , "node1" , false )
149149
150150 simulateDaemonSetAnnotation (node , constants .RebootRequired )
151151
@@ -158,8 +158,8 @@ var _ = Describe("Drain Controller", Ordered, func() {
158158 })
159159
160160 It ("should drain on reboot for multiple node" , func (ctx context.Context ) {
161- node , nodeState := createNode (ctx , "node1" )
162- createNode (ctx , "node2" )
161+ node , nodeState := createNode (ctx , "node1" , false )
162+ createNode (ctx , "node2" , false )
163163
164164 simulateDaemonSetAnnotation (node , constants .RebootRequired )
165165
@@ -175,9 +175,9 @@ var _ = Describe("Drain Controller", Ordered, func() {
175175 Context ("when there are multiple nodes" , func () {
176176
177177 It ("should drain nodes serially with default pool selector" , func (ctx context.Context ) {
178- node1 , nodeState1 := createNode (ctx , "node1" )
179- node2 , nodeState2 := createNode (ctx , "node2" )
180- node3 , nodeState3 := createNode (ctx , "node3" )
178+ node1 , nodeState1 := createNode (ctx , "node1" , false )
179+ node2 , nodeState2 := createNode (ctx , "node2" , false )
180+ node3 , nodeState3 := createNode (ctx , "node3" , false )
181181
182182 // Two nodes require to drain at the same time
183183 simulateDaemonSetAnnotation (node1 , constants .DrainRequired )
@@ -215,9 +215,9 @@ var _ = Describe("Drain Controller", Ordered, func() {
215215 })
216216
217217 It ("should drain nodes in parallel with a custom pool selector" , func (ctx context.Context ) {
218- node1 , nodeState1 := createNode (ctx , "node1" )
219- node2 , nodeState2 := createNode (ctx , "node2" )
220- node3 , nodeState3 := createNode (ctx , "node3" )
218+ node1 , nodeState1 := createNode (ctx , "node1" , false )
219+ node2 , nodeState2 := createNode (ctx , "node2" , false )
220+ node3 , nodeState3 := createNode (ctx , "node3" , false )
221221
222222 maxun := intstr .Parse ("2" )
223223 poolConfig := & sriovnetworkv1.SriovNetworkPoolConfig {}
@@ -266,9 +266,9 @@ var _ = Describe("Drain Controller", Ordered, func() {
266266 })
267267
268268 It ("should drain nodes in parallel with a custom pool selector and honor MaxUnavailable" , func (ctx context.Context ) {
269- node1 , nodeState1 := createNode (ctx , "node1" )
270- node2 , nodeState2 := createNode (ctx , "node2" )
271- node3 , nodeState3 := createNode (ctx , "node3" )
269+ node1 , nodeState1 := createNode (ctx , "node1" , false )
270+ node2 , nodeState2 := createNode (ctx , "node2" , false )
271+ node3 , nodeState3 := createNode (ctx , "node3" , false )
272272
273273 maxun := intstr .Parse ("2" )
274274 poolConfig := & sriovnetworkv1.SriovNetworkPoolConfig {}
@@ -291,9 +291,9 @@ var _ = Describe("Drain Controller", Ordered, func() {
291291 })
292292
293293 It ("should drain all nodes in parallel with a custom pool using nil in max unavailable" , func (ctx context.Context ) {
294- node1 , nodeState1 := createNode (ctx , "node1" )
295- node2 , nodeState2 := createNode (ctx , "node2" )
296- node3 , nodeState3 := createNode (ctx , "node3" )
294+ node1 , nodeState1 := createNode (ctx , "node1" , false )
295+ node2 , nodeState2 := createNode (ctx , "node2" , false )
296+ node3 , nodeState3 := createNode (ctx , "node3" , false )
297297
298298 poolConfig := & sriovnetworkv1.SriovNetworkPoolConfig {}
299299 poolConfig .SetNamespace (testNamespace )
@@ -319,7 +319,7 @@ var _ = Describe("Drain Controller", Ordered, func() {
319319 })
320320
321321 It ("should drain in parallel nodes from two different pools, one custom and one default" , func () {
322- node1 , nodeState1 := createNode (ctx , "node1" )
322+ node1 , nodeState1 := createNode (ctx , "node1" , false )
323323 node2 , nodeState2 := createNodeWithLabel (ctx , "node2" , "pool" )
324324 createPodOnNode (ctx , "test-node-2" , "node2" )
325325
@@ -342,7 +342,7 @@ var _ = Describe("Drain Controller", Ordered, func() {
342342 })
343343
344344 It ("should select all the nodes to drain in parallel when the selector is empty" , func () {
345- node1 , nodeState1 := createNode (ctx , "node3" )
345+ node1 , nodeState1 := createNode (ctx , "node3" , false )
346346 node2 , nodeState2 := createNodeWithLabel (ctx , "node4" , "pool" )
347347 createPodOnNode (ctx , "test-empty-1" , "node3" )
348348 createPodOnNode (ctx , "test-empty-2" , "node4" )
@@ -424,7 +424,7 @@ func simulateDaemonSetAnnotation(node *corev1.Node, drainAnnotationValue string)
424424 ToNot (HaveOccurred ())
425425}
426426
427- func createNode (ctx context.Context , nodeName string ) (* corev1.Node , * sriovnetworkv1.SriovNetworkNodeState ) {
427+ func createNode (ctx context.Context , nodeName string , useExternalDrainer bool ) (* corev1.Node , * sriovnetworkv1.SriovNetworkNodeState ) {
428428 node := corev1.Node {
429429 ObjectMeta : metav1.ObjectMeta {
430430 Name : nodeName ,
@@ -448,6 +448,10 @@ func createNode(ctx context.Context, nodeName string) (*corev1.Node, *sriovnetwo
448448 },
449449 }
450450
451+ if useExternalDrainer {
452+ nodeState .Annotations [constants .NodeStateExternalDrainerAnnotation ] = "true"
453+ }
454+
451455 Expect (k8sClient .Create (ctx , & node )).ToNot (HaveOccurred ())
452456 Expect (k8sClient .Create (ctx , & nodeState )).ToNot (HaveOccurred ())
453457
0 commit comments