Bug 1726168

Summary: NameError: global name 'BrokenPipeError' is not defined
Product: Red Hat Enterprise Linux 7 Reporter: Xiaodai Wang <xiaodwan>
Component: libguestfsAssignee: Pino Toscano <ptoscano>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 7.7CC: jomurphy, jsuchane, juzhou, mtessun, mxie, ptoscano, rcadova, toneata, tzheng, xiaodwan, zili
Target Milestone: rcKeywords: Regression, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.40.2-6.el7 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 1730708 1731428 (view as bug list) Environment:
Last Closed: 2020-03-31 19:55:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1730708, 1731428    
Attachments:
Description Flags
v2v log none

Description Xiaodai Wang 2019-07-02 09:19:42 UTC
Description of problem:
NameError: global name 'BrokenPipeError' is not defined

Version-Release number of selected component (if applicable):
virt-v2v-1.40.2-5.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Prepare a regular host(non ovirt host), Use virt-v2v to convert a guest to rhv with rhv-upload option:
# virt-v2v -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1 esx6.7-rhel7.5-x86_64 --password-file /tmp/passwd -on rhel7.5-log -o rhv-upload -oc https://ibm-x3250m5-03.rhts.eng.pek2.redhat.com/ovirt-engine/api -os p2v_data -op /tmp/rhvpasswd -oo rhv-cafile=/home/ca.pem -oo rhv-direct=true -oo rhv-cluster=p2v

2.Wait until the transfer starts, and note the ticket value in ovirt-imageio-daemon log in ovirt host which the vm will be running on:
# cat /var/log/ovirt-imageio-daemon/daemon.log | grep ADD | tail -1

2019-04-18 17:35:16,049 INFO    (Thread-2239) [tickets] [local] ADD ticket={u'uuid': u'49f50a5b-e8b4-465b-a63c-aec476216c82', u'ops': [u'write'], u'url': u'file:///rhev/data-center/mnt/10.73.224.199:_home_p2v__data/7b22dda5-0c99-4bdb-852b-c41332094b02/images/151ed16b-56fd-44b8-96f5-acb7deb56426/50089966-4eea-43d5-8686-9141543f1d55', u'sparse': True, u'timeout': 300, u'transfer_id': u'd690fa40-322b-4d17-9838-0b340d665306', u'size': 12884901888}

3. Make the ticket expire in one second by sending this request:
#  curl --unix-socket /run/vdsm/ovirt-imageio-daemon.sock -X PATCH -d '{"timeout": 1}' http://localhost/tickets/49f50a5b-e8b4-465b-a63c-aec476216c82

4.Check the error message:

Actual results:
nbdkit: python[1]: error: /var/tmp/v2v.4MjouT/rhv-upload-plugin.py: pwrite: error: ['Traceback (most recent call last):\n', '  File "/var/tmp/v2v.4MjouT/rhv-upload-plugin.py", line 398, in pwrite\n    except BrokenPipeError:\n', "NameError: global name 'BrokenPipeError' is not defined\n"]
nbdkit: python[1]: debug: sending error reply: Input/output error
qemu-img: error while writing sector 1071232: Input/output error

nbdkit: python[1]: debug: flush
nbdkit: python[1]: error: /var/tmp/v2v.4MjouT/rhv-upload-plugin.py: flush: error: ['Traceback (most recent call last):\n', '  File "/var/tmp/v2v.4MjouT/rhv-upload-plugin.py", line 503, in flush\n    http.request("PATCH", h[\'path\'], body=buf, headers=headers)\n', '  File "/usr/lib64/python2.7/httplib.py", line 1056, in request\n    self._send_request(method, url, body, headers)\n', '  File "/usr/lib64/python2.7/httplib.py", line 1084, in _send_request\n    self.putrequest(method, url, **skips)\n', '  File "/usr/lib64/python2.7/httplib.py", line 932, in putrequest\n    raise CannotSendRequest()\n', 'CannotSendRequest\n']
nbdkit: python[1]: debug: sending error reply: Input/output error
nbdkit: python[1]: debug: flush
nbdkit: python[1]: error: /var/tmp/v2v.4MjouT/rhv-upload-plugin.py: flush: error: ['Traceback (most recent call last):\n', '  File "/var/tmp/v2v.4MjouT/rhv-upload-plugin.py", line 503, in flush\n    http.request("PATCH", h[\'path\'], body=buf, headers=headers)\n', '  File "/usr/lib64/python2.7/httplib.py", line 1056, in request\n    self._send_request(method, url, body, headers)\n', '  File "/usr/lib64/python2.7/httplib.py", line 1084, in _send_request\n    self.putrequest(method, url, **skips)\n', '  File "/usr/lib64/python2.7/httplib.py", line 932, in putrequest\n    raise CannotSendRequest()\n', 'CannotSendRequest\n']
nbdkit: python[1]: debug: sending error reply: Input/output error
nbdkit: python[1]: debug: client sent disconnect command, closing connection
nbdkit: python[1]: debug: close
virt-v2v: error: qemu-img command failed, see earlier errors
nbdkit: python[1]: error: /var/tmp/v2v.4MjouT/rhv-upload-plugin.py: close: error: ['Traceback (most recent call last):\n', '  File "/var/tmp/v2v.4MjouT/rhv-upload-plugin.py", line 567, in close\n    delete_disk_on_failure(h)\n', '  File "/var/tmp/v2v.4MjouT/rhv-upload-plugin.py", line 513, in delete_disk_on_failure\n    disk_service.remove()\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 37334, in remove\n    self._internal_remove(headers, query, wait)\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 271, in _internal_remove\n    return future.wait() if wait else future\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 55, in wait\n    return self._code(response)\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 268, in callback\n    self._check_fault(response)\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 132, in _check_fault\n    self._raise_error(response, body)\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 118, in _raise_error\n    raise error\n', 'Error: Fault reason is "Operation Failed". Fault detail is "[Cannot remove Virtual Disk. Related operation is currently in progress. Please try again later.]". HTTP response code is 409.\n']


Expected results:
No this exception: NameError: global name 'BrokenPipeError' is not defined

Additional info:

Comment 3 Xiaodai Wang 2019-07-02 09:23:40 UTC
Created attachment 1586604 [details]
v2v log

Comment 5 Richard W.M. Jones 2019-07-02 09:38:37 UTC
Possibly relevant stackoverflow:
https://stackoverflow.com/questions/34718208/catch-broken-pipe-in-python-2-and-python-3

Comment 23 mxie@redhat.com 2019-08-16 06:49:23 UTC
Verify the bug with below builds:
virt-v2v-1.40.2-6.el7.x86_64
libguestfs-1.40.2-6.el7.x86_64
qemu-kvm-rhev-2.12.0-33.el7_7.1.x86_64
libvirt-4.5.0-23.el7.x86_64
nbdkit-1.8.0-1.el7.x86_64

Steps;
1.Convert a guest from VMware to rhv using rhv-upload on standalone v2v conversion server
#virt-v2v -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1 esx6.7-rhel7.6-x86_64 --password-file /tmp/passwd -o rhv-upload -oc https://ibm-x3250m5-03.rhts.eng.pek2.redhat.com/ovirt-engine/api -os p2v_data -op /tmp/rhvpasswd -oo rhv-cafile=/home/ca.pem -oo rhv-direct=true -oo rhv-cluster=p2v


2.Waiting for the copying disk starts in above v2v conversion and check the ticket ID of this conversion in ovirt-imageio-daemon log on rhv-node 'p2v', then execute the command of steps2.2 constantly to make the ticket expired 

2.1 # cat /var/log/ovirt-imageio-daemon/daemon.log | grep ADD | tail -1
2019-08-16 14:28:37,149 INFO    (Thread-778) [tickets] [local] ADD ticket={u'uuid': u'3f7867e5-5c86-47bb-a44e-da754e9389f3', u'ops': [u'write'], u'url': u'file:///rhev/data-center/mnt/10.73.224.199:_home_p2v__data/6f298424-7d5b-4310-9eb4-f69871065298/images/d905fad7-bc33-441b-8885-8c8019a1f727/552794ba-c794-4903-97f4-92d41716928d', u'sparse': True, u'timeout': 300, u'transfer_id': u'48814401-03b7-416e-8f94-dcca8ca5c8f5', u'size': 17179869184}

2.2 #  curl --unix-socket /run/vdsm/ovirt-imageio-daemon.sock -X PATCH -d '{"timeout": 1}' http://localhost/tickets/3f7867e5-5c86-47bb-a44e-da754e9389f3


3.Found the v2v conversion of step1 is failed with below error which is expected result 
# virt-v2v -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1 esx6.7-rhel7.6-x86_64 --password-file /tmp/passwd -o rhv-upload -oc https://ibm-x3250m5-03.rhts.eng.pek2.redhat.com/ovirt-engine/api -os p2v_data -op /tmp/rhvpasswd -oo rhv-cafile=/home/ca.pem -oo rhv-direct=true -oo rhv-cluster=p2v
Exception AttributeError: "'module' object has no attribute 'dump_plugin'" in <module 'threading' from '/usr/lib64/python2.7/threading.pyc'> ignored
[   0.8] Opening the source -i libvirt -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1 esx6.7-rhel7.6-x86_64
[   3.4] Creating an overlay to protect the source from being modified
[   4.5] Opening the overlay
[  81.7] Inspecting the overlay
[ 308.9] Checking for sufficient free disk space in the guest
[ 308.9] Estimating space required on target for each disk
[ 308.9] Converting Red Hat Enterprise Linux Server 7.6 (Maipo) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[1785.5] Mapping filesystem data to avoid copying unused and blank areas
[1787.5] Closing the overlay
[1787.9] Assigning disks to buses
[1787.9] Checking if the guest needs BIOS or UEFI to boot
[1787.9] Initializing the target -o rhv-upload -oc https://ibm-x3250m5-03.rhts.eng.pek2.redhat.com/ovirt-engine/api -op /tmp/rhvpasswd -os p2v_data
[1789.4] Copying disk 1/1 to qemu URI json:{ "file.driver": "nbd", "file.path": "/var/tmp/rhvupload.5nKw4Z/nbdkit0.sock", "file.export": "/" } (raw)
nbdkit: python[1]: error: /var/tmp/v2v.JI61Tq/rhv-upload-plugin.py: pwrite: error: ['Traceback (most recent call last):\n', '  File "/var/tmp/v2v.JI61Tq/rhv-upload-plugin.py", line 407, in pwrite\n    (offset, count))\n', '  File "/var/tmp/v2v.JI61Tq/rhv-upload-plugin.py", line 355, in request_failed\n    raise RuntimeError("%s: %d %s: %r" % (msg, status, reason, body[:200]))\n', "RuntimeError: could not write sector offset 2795503616 size 16384: 403 Forbidden: 'You are not allowed to access this resource: Ticket 3f7867e5-5c86-47bb-a44e-da754e9389f3 expired'\n"]
qemu-img: error while writing sector 5459968: Input/output error

nbdkit: python[1]: error: /var/tmp/v2v.JI61Tq/rhv-upload-plugin.py: flush: error: ['Traceback (most recent call last):\n', '  File "/var/tmp/v2v.JI61Tq/rhv-upload-plugin.py", line 510, in flush\n    request_failed(h, r, "could not flush")\n', '  File "/var/tmp/v2v.JI61Tq/rhv-upload-plugin.py", line 355, in request_failed\n    raise RuntimeError("%s: %d %s: %r" % (msg, status, reason, body[:200]))\n', "RuntimeError: could not flush: 403 Forbidden: 'You are not allowed to access this resource: Ticket 3f7867e5-5c86-47bb-a44e-da754e9389f3 expired'\n"]
nbdkit: python[1]: error: /var/tmp/v2v.JI61Tq/rhv-upload-plugin.py: flush: error: ['Traceback (most recent call last):\n', '  File "/var/tmp/v2v.JI61Tq/rhv-upload-plugin.py", line 510, in flush\n    request_failed(h, r, "could not flush")\n', '  File "/var/tmp/v2v.JI61Tq/rhv-upload-plugin.py", line 355, in request_failed\n    raise RuntimeError("%s: %d %s: %r" % (msg, status, reason, body[:200]))\n', "RuntimeError: could not flush: 403 Forbidden: 'You are not allowed to access this resource: Ticket 3f7867e5-5c86-47bb-a44e-da754e9389f3 expired'\n"]
virt-v2v: error: qemu-img command failed, see earlier errors

If reporting bugs, run virt-v2v with debugging enabled and include the 
complete output:

  virt-v2v -v -x [...]
nbdkit: python[1]: error: /var/tmp/v2v.JI61Tq/rhv-upload-plugin.py: close: error: ['Traceback (most recent call last):\n', '  File "/var/tmp/v2v.JI61Tq/rhv-upload-plugin.py", line 530, in close\n    delete_disk_on_failure(h)\n', '  File "/var/tmp/v2v.JI61Tq/rhv-upload-plugin.py", line 516, in delete_disk_on_failure\n    disk_service.remove()\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 37373, in remove\n    self._internal_remove(headers, query, wait)\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 271, in _internal_remove\n    return future.wait() if wait else future\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 55, in wait\n    return self._code(response)\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 268, in callback\n    self._check_fault(response)\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 132, in _check_fault\n    self._raise_error(response, body)\n', '  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 118, in _raise_error\n    raise error\n', 'Error: Fault reason is "Operation Failed". Fault detail is "[Cannot remove Virtual Disk. Related operation is currently in progress. Please try again later.]". HTTP response code is 409.\n']


Result:
    The error info has been improved when make the ticket of v2v conversion expired on standalone v2v server,so change the bug from ON_QA to VERIFIED.

Comment 25 errata-xmlrpc 2020-03-31 19:55:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:1082