Skip to content

Commit

Permalink
Add retries to orchestra.connection.connect()
Browse files Browse the repository at this point in the history
This is an attempt to fix: http://tracker.ceph.com/issues/8314

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
  • Loading branch information
zmc committed May 12, 2014
1 parent dfb2352 commit d945e56
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 14 additions & 1 deletion teuthology/orchestra/connection.py
Expand Up @@ -4,7 +4,12 @@
import base64
import paramiko
import os
import logging

from ..config import config
from ..contextutil import safe_while

log = logging.getLogger(__name__)


def split_user(user_at_host):
Expand Down Expand Up @@ -85,7 +90,15 @@ def connect(user_at_host, host_key=None, keep_alive=False,
if opt_name in opts:
connect_args[arg_name] = opts[opt_name]

log.info(connect_args)

# just let the exceptions bubble up to caller
ssh.connect(**connect_args)
with safe_while(sleep=1, action='connect to ' + host) as proceed:
while proceed():
try:
ssh.connect(**connect_args)
break
except paramiko.AuthenticationException:
log.exception("Error connecting to {host}".format(host=host))
ssh.get_transport().set_keepalive(keep_alive)
return ssh
8 changes: 5 additions & 3 deletions teuthology/orchestra/test/test_connection.py
@@ -1,13 +1,15 @@
from teuthology import config

import fudge

from teuthology import config
from .util import assert_raises

from .. import connection


class TestConnection(object):
def setup(self):
import time
time.sleep = lambda s: True

def clear_config(self):
config.config.teuthology_yaml = ''
config.config.load_files()
Expand Down

0 comments on commit d945e56

Please sign in to comment.