@@ -18,6 +18,7 @@ package windows
18
18
19
19
import (
20
20
"context"
21
+ "strconv"
21
22
"time"
22
23
23
24
"github.com/onsi/ginkgo/v2"
@@ -50,7 +51,10 @@ var _ = sigDescribe(feature.Windows, "[Excluded:WindowsDocker] [MinimumKubeletVe
50
51
framework .ExpectNoError (err , "Error finding Windows node" )
51
52
framework .Logf ("Using node: %v" , targetNode .Name )
52
53
53
- bootID := targetNode .Status .NodeInfo .BootID
54
+ bootID , err := strconv .Atoi (targetNode .Status .NodeInfo .BootID )
55
+ framework .ExpectNoError (err , "Error converting bootID to int" )
56
+ framework .Logf ("Initial BootID: %d" , bootID )
57
+
54
58
windowsImage := imageutils .GetE2EImage (imageutils .Agnhost )
55
59
56
60
// Create Windows pod on the selected Windows node Using Agnhost
@@ -177,24 +181,40 @@ var _ = sigDescribe(feature.Windows, "[Excluded:WindowsDocker] [MinimumKubeletVe
177
181
178
182
restartCount := 0
179
183
180
- ginkgo .By ("Waiting for nodes to be rebooted" )
181
- gomega .Eventually (ctx , func (ctx context.Context ) string {
182
- refreshNode , err := f .ClientSet .CoreV1 ().Nodes ().Get (ctx , targetNode .Name , metav1.GetOptions {})
183
- if err != nil {
184
- return ""
184
+ timeout := time .After (time .Minute * 10 )
185
+ FOR:
186
+ for {
187
+ select {
188
+ case <- timeout :
189
+ break FOR
190
+ default :
191
+ if restartCount > 0 {
192
+ break FOR
193
+ }
194
+ ginkgo .By ("Then checking existed agn-test-pod is running on the rebooted host" )
195
+ agnPodOut , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Get (ctx , agnPod .Name , metav1.GetOptions {})
196
+ if err == nil {
197
+ lastRestartCount := podutil .GetExistingContainerStatus (agnPodOut .Status .ContainerStatuses , "windows-container" ).RestartCount
198
+ restartCount = int (lastRestartCount - initialRestartCount )
199
+ }
200
+ time .Sleep (time .Second * 30 )
185
201
}
186
- return refreshNode .Status .NodeInfo .BootID
187
- }).WithPolling (time .Second * 30 ).WithTimeout (time .Minute * 10 ).
188
- Should (gomega .BeNumerically (">" , bootID ), "node was not rebooted" )
202
+ }
189
203
190
- ginkgo .By ("Then checking existed agn-test-pod is running on the rebooted host" )
191
- agnPodOut , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Get (ctx , agnPod .Name , metav1.GetOptions {})
192
- framework .ExpectNoError (err , "getting pod info after reboot" )
204
+ ginkgo .By ("Checking whether the node is rebooted" )
205
+ refreshNode , err := f .ClientSet .CoreV1 ().Nodes ().Get (ctx , targetNode .Name , metav1.GetOptions {})
206
+ framework .ExpectNoError (err , "Error getting node info after reboot" )
207
+ currentbootID , err := strconv .Atoi (refreshNode .Status .NodeInfo .BootID )
208
+ framework .ExpectNoError (err , "Error converting bootID to int" )
209
+ framework .Logf ("current BootID: %d" , currentbootID )
210
+ gomega .Expect (currentbootID ).To (gomega .Equal (bootID + 1 ), "BootID should be incremented by 1 after reboot" )
193
211
194
- lastRestartCount := podutil .GetExistingContainerStatus (agnPodOut .Status .ContainerStatuses , "windows-container" ).RestartCount
195
- restartCount = int (lastRestartCount - initialRestartCount )
212
+ ginkgo .By ("Checking whether agn-test-pod is rebooted" )
196
213
gomega .Expect (restartCount ).To (gomega .Equal (1 ), "restart count of agn-test-pod is 1" )
214
+
215
+ agnPodOut , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Get (ctx , agnPod .Name , metav1.GetOptions {})
197
216
gomega .Expect (agnPodOut .Status .Phase ).To (gomega .Equal (v1 .PodRunning ))
217
+ framework .ExpectNoError (err , "getting pod info after reboot" )
198
218
assertConsistentConnectivity (ctx , f , nginxPod .ObjectMeta .Name , "linux" , linuxCheck (agnPodOut .Status .PodIP , 80 ), internalMaxTries )
199
219
200
220
// create another host process pod to check system boot time
0 commit comments