fix: do not continue retrying when qemu is dead
This commit is contained in:
parent
b8058bffb0
commit
7d0ee9a1dc
@ -374,13 +374,17 @@ func (q *System) WaitForSSH(timeout time.Duration) error {
|
|||||||
return errors.New("no ssh (timeout)")
|
return errors.New("no ssh (timeout)")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q System) ssh(user string) (client *ssh.Client, err error) {
|
func (q *System) ssh(user string) (client *ssh.Client, err error) {
|
||||||
cfg := &ssh.ClientConfig{
|
cfg := &ssh.ClientConfig{
|
||||||
User: user,
|
User: user,
|
||||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||||
}
|
}
|
||||||
|
|
||||||
for retries := q.SSH.Retries; retries > 0; retries-- {
|
for retries := q.SSH.Retries; retries > 0; retries-- {
|
||||||
|
if q.Died {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
client, err = ssh.Dial("tcp", q.SSH.AddrPort, cfg)
|
client, err = ssh.Dial("tcp", q.SSH.AddrPort, cfg)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
@ -512,8 +516,12 @@ func (q System) scp(user, localPath, remotePath string, recursive bool) (err err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q System) scpWithRetry(user, localPath, remotePath string, recursive bool) (err error) {
|
func (q *System) scpWithRetry(user, localPath, remotePath string, recursive bool) (err error) {
|
||||||
for retries := q.SSH.Retries; retries > 0; retries-- {
|
for retries := q.SSH.Retries; retries > 0; retries-- {
|
||||||
|
if q.Died {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = q.scp(user, localPath, remotePath, recursive)
|
err = q.scp(user, localPath, remotePath, recursive)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user