Bug 2103093

Summary: upload of 2.8 GiB SRPM over slow network dies with division by zero
Product: [Fedora] Fedora Reporter: Kamil Dudka <kdudka>
Component: python-progressAssignee: Pavel Raiskup <praiskup>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 35CC: clime7, copr-team, imvalgo, jkadlcik, kdudka, msuchy, praiskup, python-sig, slavek.kabrda, turecek.dominik
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-progress-1.6-4.fc37 python-progress-1.6-4.el9 python-progress-1.6-4.fc36 python-progress-1.6-4.fc35 python-progress-1.6-4.el8 python-progress-1.6-4.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 15:35:33 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:

Description Kamil Dudka 2022-07-01 12:30:32 UTC
Description of problem:
When I try to upload a 2.8 GiB SRPM over an O2 Fiber connection from my flat, the copr-cli process is terminated with traceback showing a division by zero in python-progress.


Version-Release number of selected component (if applicable):
copr-cli-1.100-1.fc35.noarch
python3-progress-1.5-10.fc35.noarch


Steps to Reproduce:
1. copr-cli --config=/home/kdudka/.config/copr-kdudka build --nowait covscan src/cov-sa202206-2022.6.0-4.fc35.src.rpm


Actual results:
Uploading package src/cov-sa202206-2022.6.0-4.fc35.src.rpm
 |#                               | 145.2 MB 5.0 kB/s eta 6 days, 11:28:19
Traceback (most recent call last):
  File "/usr/bin/copr-cli", line 33, in <module>
    sys.exit(load_entry_point('copr-cli==1.100', 'console_scripts', 'copr-cli')())
  File "/usr/lib/python3.10/site-packages/copr_cli/main.py", line 1827, in main
    getattr(commands, arg.func)(arg)
  File "/usr/lib/python3.10/site-packages/copr_cli/main.py", line 140, in wrapper
    return func(self, args)
  File "/usr/lib/python3.10/site-packages/copr_cli/main.py", line 342, in action_build
    builds.append(self.process_build(args, build_function, data, bar=bar, progress_callback=progress_callback))
  File "/usr/lib/python3.10/site-packages/copr_cli/main.py", line 431, in process_build
    result = build_function(ownername=username, projectname=projectname,
  File "/usr/lib/python3.10/site-packages/copr/v3/helpers.py", line 68, in wrapper
    result = func(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/copr/v3/proxies/build.py", line 150, in create_from_file
    return self._create(endpoint, data, files=files, buildopts=buildopts)
  File "/usr/lib/python3.10/site-packages/copr/v3/helpers.py", line 68, in wrapper
    result = func(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/copr/v3/proxies/build.py", line 307, in _create
    response = request.send(
  File "/usr/lib/python3.10/site-packages/copr/v3/requests.py", line 50, in send
    response = self._send_request_repeatedly(session, request_params)
  File "/usr/lib/python3.10/site-packages/copr/v3/requests.py", line 61, in _send_request_repeatedly
    response = session.request(**request_params)
  File "/usr/lib/python3.10/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.10/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.10/site-packages/requests/adapters.py", line 440, in send
    resp = conn.urlopen(
  File "/usr/lib/python3.10/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3.10/site-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.10/site-packages/urllib3/connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/lib64/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.10/http/client.py", line 1066, in _send_output
    for chunk in chunks:
  File "/usr/lib64/python3.10/http/client.py", line 1021, in _read_readable
    datablock = readable.read(self.blocksize)
  File "/usr/lib/python3.10/site-packages/requests_toolbelt/multipart/encoder.py", line 403, in read
    self.callback(self)
  File "/usr/lib/python3.10/site-packages/copr_cli/main.py", line 331, in progress_callback
    bar.next(n=8192)
  File "/usr/lib/python3.10/site-packages/progress/__init__.py", line 146, in next
    self.update()
  File "/usr/lib/python3.10/site-packages/progress/bar.py", line 39, in update
    suffix = self.suffix % self
  File "/usr/lib/python3.10/site-packages/progress/__init__.py", line 94, in __getitem__
    return getattr(self, key, None)
  File "/usr/lib/python3.10/site-packages/copr_cli/util.py", line 19, in download_speed
    if self.avg == 0.0:
  File "/usr/lib/python3.10/site-packages/progress/__init__.py", line 102, in avg
    speed = self.window.avg
  File "/usr/lib/python3.10/site-packages/progress/__init__.py", line 63, in avg
    return self.counter / (self.last - self.deque[0][0])
ZeroDivisionError: float division by zero

Comment 1 Kamil Dudka 2022-07-01 12:43:17 UTC
I ended up with the following hotfix in progress/__init__.py:

    @property
    def avg(self):
        x = self.last - self.deque[0][0]
        if x <= 0.0 and x >= 0.0:
            return float('inf')
        else:
            return self.counter / x

Comment 2 Pavel Raiskup 2022-07-02 09:11:35 UTC
Thank you for the report and patch.  The situation is very weird.  Unless
(a) the connection is _very_ unstable, and the box is _very_ fast, OR
(b) the time() on the box goes backward,
I'm clueless.  This is the proposed fix for both a) and b) situations:
https://src.fedoraproject.org/rpms/python-progress/pull-request/5

Comment 3 Kamil Dudka 2022-07-04 07:14:40 UTC
Thank you for the quick fix!  I will retest it when I am back on my home network.

Comment 4 Kamil Dudka 2022-07-04 21:09:05 UTC
I wanted to verify the fix.  Unfortunately, I am not able to trigger the traceback captured in comment #0 right now any more.

Comment 5 Fedora Update System 2022-07-05 08:00:08 UTC
FEDORA-2022-55f18fa50e has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-55f18fa50e

Comment 6 Fedora Update System 2022-07-05 08:04:01 UTC
FEDORA-2022-3f942d3b4f has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-3f942d3b4f

Comment 7 Fedora Update System 2022-07-05 08:04:02 UTC
FEDORA-EPEL-2022-6f72c19cfc has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2022-6f72c19cfc

Comment 8 Fedora Update System 2022-07-05 08:04:03 UTC
FEDORA-EPEL-2022-cb1d0a0321 has been submitted as an update to Fedora EPEL 8. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2022-cb1d0a0321

Comment 9 Fedora Update System 2022-07-05 08:04:05 UTC
FEDORA-EPEL-2022-1b7daed183 has been submitted as an update to Fedora EPEL 9. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2022-1b7daed183

Comment 10 Fedora Update System 2022-07-05 08:04:06 UTC
FEDORA-2022-210571b2ac has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-210571b2ac

Comment 11 Pavel Raiskup 2022-07-05 08:09:05 UTC
> I wanted to verify the fix.  Unfortunately, I am not able to trigger the
> traceback captured in comment #0 right now any more.

No problem, the issue you faced before was weird, and unlikely.  Thank you
for the attempt at least!  The PR is correct anyway, I believe.  So I
merged and built.  Please reopen if you face the same issue again.

Comment 12 Fedora Update System 2022-07-05 15:35:33 UTC
FEDORA-2022-55f18fa50e has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 13 Fedora Update System 2022-07-06 01:24:21 UTC
FEDORA-2022-3f942d3b4f has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-3f942d3b4f`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-3f942d3b4f

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 14 Fedora Update System 2022-07-06 02:15:52 UTC
FEDORA-2022-210571b2ac has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-210571b2ac`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-210571b2ac

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 15 Fedora Update System 2022-07-06 02:22:57 UTC
FEDORA-EPEL-2022-1b7daed183 has been pushed to the Fedora EPEL 9 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2022-1b7daed183

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 16 Fedora Update System 2022-07-06 02:32:26 UTC
FEDORA-EPEL-2022-cb1d0a0321 has been pushed to the Fedora EPEL 8 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2022-cb1d0a0321

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 17 Fedora Update System 2022-07-08 02:22:16 UTC
FEDORA-EPEL-2022-6f72c19cfc has been pushed to the Fedora EPEL 7 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2022-6f72c19cfc

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 18 Fedora Update System 2022-07-14 01:41:39 UTC
FEDORA-EPEL-2022-1b7daed183 has been pushed to the Fedora EPEL 9 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 19 Fedora Update System 2022-07-14 01:45:37 UTC
FEDORA-2022-210571b2ac has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 20 Fedora Update System 2022-07-14 01:56:55 UTC
FEDORA-2022-3f942d3b4f has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 21 Fedora Update System 2022-07-14 02:07:10 UTC
FEDORA-EPEL-2022-cb1d0a0321 has been pushed to the Fedora EPEL 8 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 22 Fedora Update System 2022-07-16 02:03:12 UTC
FEDORA-EPEL-2022-6f72c19cfc has been pushed to the Fedora EPEL 7 stable repository.
If problem still persists, please make note of it in this bug report.