Fix the node reboot validation failure

This commit is contained in:
zylxjtu 2025-02-20 21:28:38 +00:00
parent 052d7a5310
commit f1612003ff

View File

@ -18,6 +18,7 @@ package windows
import ( import (
"context" "context"
"strconv"
"time" "time"
"github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2"
@ -50,7 +51,8 @@ var _ = sigDescribe(feature.Windows, "[Excluded:WindowsDocker] [MinimumKubeletVe
framework.ExpectNoError(err, "Error finding Windows node") framework.ExpectNoError(err, "Error finding Windows node")
framework.Logf("Using node: %v", targetNode.Name) framework.Logf("Using node: %v", targetNode.Name)
bootID := targetNode.Status.NodeInfo.BootID bootID, err := strconv.Atoi(targetNode.Status.NodeInfo.BootID)
framework.ExpectNoError(err, "Error converting bootID to int")
windowsImage := imageutils.GetE2EImage(imageutils.Agnhost) windowsImage := imageutils.GetE2EImage(imageutils.Agnhost)
// Create Windows pod on the selected Windows node Using Agnhost // Create Windows pod on the selected Windows node Using Agnhost
@ -178,12 +180,17 @@ var _ = sigDescribe(feature.Windows, "[Excluded:WindowsDocker] [MinimumKubeletVe
restartCount := 0 restartCount := 0
ginkgo.By("Waiting for nodes to be rebooted") ginkgo.By("Waiting for nodes to be rebooted")
gomega.Eventually(ctx, func(ctx context.Context) string { gomega.Eventually(ctx, func(ctx context.Context) int {
refreshNode, err := f.ClientSet.CoreV1().Nodes().Get(ctx, targetNode.Name, metav1.GetOptions{}) refreshNode, err := f.ClientSet.CoreV1().Nodes().Get(ctx, targetNode.Name, metav1.GetOptions{})
if err != nil { if err != nil {
return "" return -1
}
num, err := strconv.Atoi(refreshNode.Status.NodeInfo.BootID) // Attempt to convert empty string
if err != nil {
return -1 // strconv.Atoi: parsing "": invalid syntax
} else {
return num
} }
return refreshNode.Status.NodeInfo.BootID
}).WithPolling(time.Second*30).WithTimeout(time.Minute*10). }).WithPolling(time.Second*30).WithTimeout(time.Minute*10).
Should(gomega.BeNumerically(">", bootID), "node was not rebooted") Should(gomega.BeNumerically(">", bootID), "node was not rebooted")