Open drewp opened 1 year ago
Thank you for raising this @drewp, concerning given the similar #878 - at this point I'm not sure I trust paramiko's checking of the uploaded size to properly validate an upload. Worst thing is the false positive so I think a solution to that is to calculate a checksum of the file locally and after uploading to compare which should prevent any such issues.
Regarding this issue specifically - does this happen every time or only on some occaisions?
Had a second pass at the retry code and found a pyinfra bug which may well be the cause of both false-positives here! Won't fix any underlying issues but will raise the errors properly. I believe in this case it would now retry correctly and likely succeed (note paramiko does identify the failure "Failed to upload file, retrying: Failure").
Fix: https://github.com/Fizzadar/pyinfra/commit/277cb6fedd7b025940b254817b302ab1149bee76
Released just now in v2.6.1
.
With 2.6.1:
--> Starting operation: Files/Put (src=/tmp/net_traffic.aarch64, dest=/opt/net_traffic, mode=a+rx, force=True)
Failed to upload file, retrying: Failure
Failed to upload file, retrying: Failure
Failed to upload file, retrying: Failure
[pipe] Command socket/SSH error: OSError('Failure',)
[pipe] Error: executed 0/2 commands
--> pyinfra error: No hosts remaining!
:)
--> Starting operation: Files/Put (src=/tmp/net_traffic.aarch64, dest=/opt/net_traffic, mode=a+rx, force=True)
Traceback (most recent call last):
File "/stor6/my/proj/infra/env/lib/python3.10/site-packages/pyinfra/connectors/ssh.py", line 480, in _put_file
sftp.putfo(file_io, remote_location)
File "/stor6/my/proj/infra/env/lib/python3.10/site-packages/paramiko/sftp_client.py", line 714, in putfo
with self.file(remotepath, "wb") as fr:
File "/stor6/my/proj/infra/env/lib/python3.10/site-packages/paramiko/sftp_client.py", line 372, in open
t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
File "/stor6/my/proj/infra/env/lib/python3.10/site-packages/paramiko/sftp_client.py", line 822, in _request
return self._read_response(num)
File "/stor6/my/proj/infra/env/lib/python3.10/site-packages/paramiko/sftp_client.py", line 874, in _read_response
self._convert_status(msg)
File "/stor6/my/proj/infra/env/lib/python3.10/site-packages/paramiko/sftp_client.py", line 907, in _convert_status
raise IOError(text)
code=4 and text=Failure
Hm, rather annoyingly per this table code 4 is an unknown/generic failure and the text should explain more. It is interesting that the issue seems to be opening the remote file, rather than part of the upload. @drewp would you mind testing a few things here as this seems specific to your setup?:
scp
This should give us a bit more debugging direction I think 🙏!
Kind of like #878, here's another files.put silently failing to update the file. Before:
deploy.py follows:
I ran
pyinfra -vvv pipe deploy.py
.pyinfra logs:
2003,2005 suggest success, but the new file content has not actually been put:
Retrying with put(...,force=True) didn't help.
pyinfra 2.6