]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Wipe out existing id_rsa.pub and id_rsa before pushing ssh keys
authorSandon Van Ness <sandon@inktank.com>
Fri, 21 Jun 2013 01:36:58 +0000 (18:36 -0700)
committerSandon Van Ness <sandon@inktank.com>
Wed, 3 Jul 2013 21:24:56 +0000 (14:24 -0700)
A very simple change. Just touch a file first (to create it if it
doesn't yet exist so the delete doesn't error out) and then delete
it before pushing the keys to the file. This should avoid the
id_rsa.pub and id_rsa files from getting messed up due to previous
runs which were interrupted or failed (or if those files exist for
some reason). This appears to be what was causing breaking in the
ceph-deploy nightlies.

Signed-off-by: Sandon Van Ness <sandon@inktank.com>
teuthology/misc.py
teuthology/task/ssh_keys.py

index 8490fc2e857600fbc968b67ac477ed638ffb0a71..4071bf8d16ab59d66df1fc054a206ac18ad2ee80 100644 (file)
@@ -361,12 +361,14 @@ def move_file(remote, from_path, to_path, sudo=False):
         stdout=StringIO(),
         )
 
-def delete_file(remote, path, sudo=False):
+def delete_file(remote, path, sudo=False, force=False):
     args = []
     if sudo:
         args.append('sudo')
+    args.extend(['rm'])
+    if force:
+        args.extend(['-f'])
     args.extend([
-            'rm',
             '--',
             path,
             ])
index 8020f101fe554507750910623db9a5ee1361c0e0..6cadd12fb38da934fa0e217fb6def8136c24b415 100644 (file)
@@ -108,12 +108,14 @@ def push_keys_to_host(ctx, config, public_key, private_key):
             # adding a private key
             priv_key_file = '/home/{user}/.ssh/id_rsa'.format(user=username)
             priv_key_data = '{priv_key}'.format(priv_key=private_key)
+            misc.delete_file(remote, priv_key_file, force=True)
             # Hadoop requires that .ssh/id_rsa have permissions of '500'
             misc.create_file(remote, priv_key_file, priv_key_data, str(500))
 
             # then a private key
             pub_key_file = '/home/{user}/.ssh/id_rsa.pub'.format(user=username)
             pub_key_data = 'ssh-rsa {pub_key} {user_host}'.format(pub_key=public_key,user_host=str(remote))
+            misc.delete_file(remote, pub_key_file, force=True)
             misc.create_file(remote, pub_key_file, pub_key_data)
 
             # adding appropriate entries to the authorized_keys2 file for this host