@@ -220,19 +220,44 @@ func createFaultDomainMap(ctx context.Context, vs *vSphere) map[string]string {
220220 return fdMap
221221}
222222
223+ func isSSHReachable (ip string , timeout time.Duration ) error {
224+ nimbusGeneratedK8sVmPwd := GetAndExpectStringEnvVar (nimbusK8sVmPwd )
225+ sshClientConfig := & ssh.ClientConfig {
226+ User : "root" ,
227+ Auth : []ssh.AuthMethod {
228+ ssh .Password (nimbusGeneratedK8sVmPwd ),
229+ },
230+ HostKeyCallback : ssh .InsecureIgnoreHostKey (),
231+ }
232+ // Read hosts sshd port number
233+ ip , portNum , err := getPortNumAndIP (ip )
234+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
235+ addr := ip + ":" + portNum
236+ _ , err = ssh .Dial ("tcp" , addr , sshClientConfig )
237+ if err != nil {
238+ if strings .Contains (err .Error (), "connection reset by peer" ) ||
239+ strings .Contains (err .Error (), "no route to host" ) ||
240+ strings .Contains (err .Error (), "handshake failed" ) {
241+ return err // unreachable
242+ }
243+ }
244+ return nil
245+ }
246+
223247// waitForHostToBeDown wait for host to be down
224248func waitForHostToBeDown (ctx context.Context , ip string ) error {
225249 framework .Logf ("checking host status of %s" , ip )
226250 gomega .Expect (ip ).NotTo (gomega .BeNil ())
227251 gomega .Expect (ip ).NotTo (gomega .BeEmpty ())
228- // Read hosts sshd port number
252+ /* Read hosts sshd port number
229253 ip, portNum, err := getPortNumAndIP(ip)
230254 gomega.Expect(err).NotTo(gomega.HaveOccurred())
231- addr := ip + ":" + portNum
255+ addr := ip + ":" + portNum*/
232256
233257 waitErr := wait .PollUntilContextTimeout (ctx , poll * 2 , pollTimeoutShort * 2 , true ,
234258 func (ctx context.Context ) (bool , error ) {
235- _ , err := net .DialTimeout ("tcp" , addr , poll )
259+ //_, err := net.DialTimeout("tcp", addr, poll)
260+ err := isSSHReachable (ip , poll )
236261 if err == nil {
237262 framework .Logf ("host is reachable" )
238263 return false , nil
0 commit comments