Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2v: rhv-upload-plugin: Defer imageio connection
When using vddk input with certain vmware version, qemu-img may spend lot of time getting source image extents. If getting image extents takes more than 60 seconds, imageio server closes the idle connection, and the transfer will fail on the first write with: nbdkit: python[1]: error: /var/tmp/rhvupload.0OKqWA/rhv-upload-plugin.py: pwrite: error: Traceback (most recent call last): File "/var/tmp/rhvupload.0OKqWA/rhv-upload-plugin.py", line 94, in wrapper return func(h, *args) File "/var/tmp/rhvupload.0OKqWA/rhv-upload-plugin.py", line 230, in pwrite r = http.getresponse() File "/usr/lib64/python3.6/http/client.py", line 1361, in getresponse response.begin() File "/usr/lib64/python3.6/http/client.py", line 311, in begin version, status, reason = self._read_status() File "/usr/lib64/python3.6/http/client.py", line 280, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response This happens only when not using unix socket, for example when running on non-ovirt host, or ovirt host from another data center, or when using -oo rhv_direct=false When using unix socket, we close the initial HTTPSConnection, and created a new UnixHTTPConnection. This connection is not connected to the server yet. When qemu-img tries to access the server, the connection is connected automatically. Fix the issue by closing the initial connection used to get server options and initialize the handle, and storing a closed connection in the handle. Here is the flow with this change: 1. Create HTTPSConnection for getting server options 2. Close the connection[1] 3. If using unix socket, create UnixHTTPConnection. 4. Store the connection in the handle. 5. When qemu-img try to write/zero, the connection is reconnects automatically to imageio server[2] Tested by adding a 300 milliseconds delay in nbdkit file plugin. Due to the way qemu-img works, this cause more than 2 minutes delay after open() but before the first pwrite(). Without this change, the import fails consistently when using rhv_direct=false. [1] https://github.com/python/cpython/blob/34df10a9a16b38d54421eeeaf73ec89828563be7/Lib/http/client.py#L958 [2] https://github.com/python/cpython/blob/34df10a9a16b38d54421eeeaf73ec89828563be7/Lib/http/client.py#L972 Signed-off-by: Nir Soffer <nsoffer@redhat.com>
- Loading branch information