@@ -183,9 +183,20 @@ func (tc *testContext) checkAWSMetadataEndpointRouteIsRestored(t *testing.T, add
183183 if tc .CloudProvider .GetType () != config .AWSPlatformType {
184184 t .Skipf ("Skipping for %s" , tc .CloudProvider .GetType ())
185185 }
186- out , err := tc .runPowerShellSSHJob ("check-routes" , "Get-NetRoute" , address )
187- require .NoError (t , err , "error checking routes" )
188- assert .True (t , strings .Contains (out , "169.254.169.254" ), "metadata endpoint route is not restored" )
186+
187+ // To allow time for route restoration during node cleanup
188+ // since EndpointSlice discovery may have
189+ // different cleanup timing compared to Endpoints.
190+ err := wait .PollUntilContextTimeout (context .Background (), tc .retryInterval , 2 * time .Minute , true ,
191+ func (ctx context.Context ) (bool , error ) {
192+ out , err := tc .runPowerShellSSHJob ("check-routes" , "Get-NetRoute" , address )
193+ if err != nil {
194+ t .Logf ("error checking routes (will retry): %v" , err )
195+ return false , nil
196+ }
197+ return strings .Contains (out , "169.254.169.254" ), nil
198+ })
199+ require .NoError (t , err , "metadata endpoint route was not restored within timeout" )
189200}
190201
191202// waitForWindowsNodeRemoval returns when there are zero Windows nodes of the given type, machine or byoh, in the cluster
0 commit comments