Repository navigation
Closed
Description
Something to do with packet corruption..
Any ideas?
Cal
Exception
[2013-05-31 13:33:13,218] [transport.py:1404] [22522/dispatch0] starting thread (client mode): 0x295d750L
[2013-05-31 13:33:13,223] [transport.py:1404] [22522/dispatch0] Connected (version 2.0, client OpenSSH_5.5p1)
[2013-05-31 13:33:13,322] [transport.py:1404] [22522/dispatch0] kex algos:['diffie-hellman-group-exchange-sha256', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss'] client encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', '[email protected]'] server encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', '[email protected]'] client mac:['hmac-md5', 'hmac-sha1', '[email protected]', 'hmac-ripemd160', '[email protected]', 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', '[email protected]', 'hmac-ripemd160', '[email protected]', 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none', '[email protected]'] server compress:['none', '[email protected]'] client lang:[''] server lang:[''] kex follows?False
[2013-05-31 13:33:13,322] [transport.py:1404] [22522/dispatch0] Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
[2013-05-31 13:33:13,322] [transport.py:1404] [22522/dispatch0] using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
[2013-05-31 13:33:13,418] [transport.py:1404] [22522/dispatch0] Switch to new keys ...
[2013-05-31 13:33:13,419] [transport.py:1404] [22522/dispatch0] Attempting public-key auth...
[2013-05-31 13:33:13,569] [transport.py:1404] [22522/dispatch0] userauth is OK
[2013-05-31 13:33:13,908] [transport.py:1404] [22522/dispatch0] Authentication (publickey) successful!
[2013-05-31 13:33:13,933] [channel.py:1108] [22522/dispatch0] [chan 1] Max packet in: 34816 bytes
[2013-05-31 13:33:13,959] [channel.py:1108] [22522/dispatch0] [chan 1] Max packet out: 32768 bytes
[2013-05-31 13:33:13,959] [transport.py:1404] [22522/dispatch0] Secsh channel 1 opened.
[2013-05-31 13:33:13,992] [channel.py:1108] [22522/dispatch0] [chan 1] Sesch channel 1 request ok
[2013-05-31 13:33:14,014] [sftp.py:132] [22522/dispatch0] [chan 1] Opened sftp connection (server version 3)
[2013-05-31 13:33:14,015] [sftp.py:132] [22522/dispatch0] [chan 1] open('/tmp/lol', 'wb')
[2013-05-31 13:33:14,056] [sftp.py:132] [22522/dispatch0] [chan 1] open('/tmp/lol', 'wb') -> 00000000
[2013-05-31 13:33:15,253] [transport.py:1404] [22522/dispatch0] Disconnect (code 2): Packet corrupt
[2013-05-31 13:33:15,298] [sftp.py:132] [22522/dispatch0] [chan 1] close(00000000)
[2013-05-31 13:33:16,090] [rockspawn.py:206] [22522/dispatch0] Traceback (most recent call last):
File "/home/foxx/code/pippa/webapp/libs/rockspawn/rockspawn.py", line 198, in run
cls_setup_t.wait()
File "/usr/local/lib/python2.6/dist-packages/eventlet-0.12.1-py2.6.egg/eventlet/greenthread.py", line 168, in wait
return self._exit_event.wait()
File "/usr/local/lib/python2.6/dist-packages/eventlet-0.12.1-py2.6.egg/eventlet/event.py", line 120, in wait
current.throw(*self._exc)
File "/usr/local/lib/python2.6/dist-packages/eventlet-0.12.1-py2.6.egg/eventlet/greenthread.py", line 194, in main
result = function(*args, **kwargs)
File "adapters.py", line 290, in on_start
tpool.execute(self.upload_file, "/tmp/lol", "/tmp/lol")
File "/usr/local/lib/python2.6/dist-packages/eventlet-0.12.1-py2.6.egg/eventlet/tpool.py", line 76, in tworker
rv = meth(*args,**kwargs)
File "adapters.py", line 258, in upload_file
print sftp.put(local_path, remote_path)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/sftp_client.py", line 615, in put
return self.putfo(fl, remotepath, os.stat(localpath).st_size, callback, confirm)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/sftp_client.py", line 570, in putfo
fr.write(data)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/file.py", line 314, in write
self._write_all(data)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/file.py", line 439, in _write_all
count = self._write(data)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/sftp_file.py", line 168, in _write
self._reqs.append(self.sftp._async_request(type(None), CMD_WRITE, self.handle, long(self._realpos), str(data[:chunk])))
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/sftp_client.py", line 710, in _async_request
self._send_packet(t, str(msg))
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/sftp.py", line 172, in _send_packet
self._write_all(out)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/sftp.py", line 136, in _write_all
n = self.sock.send(out)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/channel.py", line 734, in send
self.transport._send_user_message(m)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/transport.py", line 1444, in _send_user_message
self._send_message(data)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/transport.py", line 1424, in _send_message
self.packetizer.send_message(data)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/packet.py", line 319, in send_message
self.write_all(out)
File "/usr/local/lib/python2.6/dist-packages/paramiko-1.10.1-py2.6.egg/paramiko/packet.py", line 269, in write_all
raise EOFError()
EOFError
[2013-05-31 13:33:16,090] [rockspawn.py:207] [22522/dispatch0] watchdog failure: uncaught process exception
[2013-05-31 13:33:16,090] [rockspawn.py:406] [22522/dispatch0] Process stopped
[2013-05-31 13:33:16,102] [rockspawn.py:692] [22503/MainProcess] watchdog: detected dead instance: dispatch0
[2013-05-31 13:33:16,102] [rockspawn.py:511] [22503/MainProcess] Stopping
Code
def upload_file(self, local_path, remote_path, verify=False):
pkey = paramiko.RSAKey.from_private_key_file(self.private_key_path)
t = paramiko.Transport((self.storage.ssh_host, 22))
t.connect(username=self.storage.ssh_user, pkey=pkey)
sftp = paramiko.SFTPClient.from_transport(t)
print sftp.put(local_path, remote_path)
return
Server side:
May 31 08:34:57 web1 sshd[15152]: Accepted publickey for pippaprod from 1.2.3.4 port 52456 ssh2
May 31 08:34:57 web1 sshd[15152]: pam_unix(sshd:session): session opened for user pippaprod by (uid=0)
May 31 08:34:57 web1 sshd[15155]: subsystem request for sftp
May 31 08:34:58 web1 sshd[15155]: Corrupted MAC on input.
May 31 08:34:58 web1 sshd[15155]: Disconnecting: Packet corrupt
May 31 08:34:58 web1 sshd[15152]: pam_unix(sshd:session): session closed for user pippaprod
Metadata
Metadata
Assignees
Labels
No labels
Activity
foxx commentedon May 31, 2013
If I remove eventlet from the equasion, the problem goes away;
I'm guessing that paramiko is not compatible with eventlet, but I'm surprised it is breaking so hard.
Cal
foxx commentedon May 31, 2013
Added some debug into eventlet, the send fails due to the socket being closed;
So it seems that the server is hard dropping the connection, which in turn raises an EOFError(). I'm going to look into the sending structure and see if eventlet is somehow causing some packet misordering or something
foxx commentedon May 31, 2013
Bit more information, it seems to happen quite randomly. I can do a transfer in one test of 300KB and it will work fine, but on the next test it will fail. If I increase the file size to 1000KB, it always fails.
I've tested with CLI scp/rsync and I do not get this same problem. I am also able to run both tests outside of eventlet with no errors.
I tried with the lowest hub possible (selects) and this did not make any difference. I tried disabling 'thread' monkey_patch, this did not make any difference.
I made eventlet print the datalen on every send() call, which resulted in;
I tried both setblocking 0/1, inside transport.py, both with no effect;
So, I printed out the data packet sizes on each packet sent, for both a failed test and a good test;
BAD TEST:
GOOD TEST:
The difference seems to be that in the good test, it sends 132 bytes after every 32756 max packet, and doesn't deviate away from this pattern much. In the bad test, there are blocks of 5x 32756 max packet, followed by a batch of 132..
To figure out what 132 was, I force raise an exception in eventlet send() and print the exception, as letting the exception follow through loses context;
So this logic seems to come from;
I tried changing the MAX_REQUEST_SIZE, both higher and lower, no effect.
I just sadly don't understand enough about how paramiko works :/
Cal
foxx commentedon May 31, 2013
Okay so, when a packet hits paramiko _write(), the chunk size is 32768. By the time it hits eventlet send(), its 32756, which means there are 12 bytes missing somewhere. Once it hits _async_request, the size is still 32768. Once it hits paramiko _send_packet, the packet size is 32797 due to struct.pack().
The next step in the stack is channel.py:send(), which then calls self.transport._send_user_message. There is also some other interesting locking/send window stuff going on in here. This waits for a lock and then executes _send_message, which seems to be where the encryption magic happens. This calls write_all(), at which point the packet size is then 32756 (so I guess something in the encryption compressed it down?)
From here, it seems that socket.timeout is being raised with the following
The line causing this in eventlet is;
I don't think I can dig up any more from this :(
bitprophet commentedon Sep 11, 2014
See #389.