Uninett / zinolib

Python library for zino
Apache License 2.0
1 stars 3 forks source link

Fix parsing of garbage input to get_event_ids #45

Closed hmpf closed 8 months ago

hmpf commented 8 months ago

Depends on #44.

Handles the following exception better:

2024-01-24 11:52:01,670 ERROR howitz /../howitz/src/howitz/error_handlers.py:46:: An unexpected exception has occurred Illegal response from server detected: '1705928363 ifi2-gw5: port "et-0/1/6" ix 719 (UN000165, ifi2-hmg9, hmg9-gw1) changed state from up to up on 1705928245\r\n.\r\n'
Traceback (most recent call last):
  File "/../zinolib/src/zinolib/ritz.py", line 391, in _request
    header = (int(rawh[0]), rawh[1])
ValueError: invalid literal for int() with base 10: 'g9-gw1)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/VENV/howitz/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/VENV/howitz/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/../howitz/src/howitz/endpoints.py", line 305, in poll_events
  File "/../howitz/src/howitz/endpoints.py", line 117, in poll_current_events
    current_app.logger.exception('Recurrent NotConnectedError %s', notConnErr)
  File "/../zinolib/src/zinolib/controllers/zino1.py", line 472, in get_events
    for event_id in self._event_adapter.get_event_ids(self.session.request):
  File "/../zinolib/src/zinolib/controllers/zino1.py", line 300, in get_event_ids
    return request.get_caseids()
  File "/../zinolib/src/zinolib/ritz.py", line 545, in get_caseids
    response = self._request(b"caseids")
  File "/../zinolib/src/zinolib/ritz.py", line 393, in _request
    raise ProtocolError(
zinolib.ritz.ProtocolError: Illegal response from server detected: '1705928363 ifi2-gw5: port "et-0/1/6" ix 719 (UN000165, ifi2-hmg9, hmg9-gw1) changed state from up to up on 1705928245\r\n.\r\n'

The ProtocolError is replaced with a RetryError.

github-actions[bot] commented 8 months ago

Test results

    3 files      3 suites   41s :stopwatch:   63 tests   63 :heavy_check_mark: 0 :zzz: 0 :x: 189 runs  189 :heavy_check_mark: 0 :zzz: 0 :x:

Results for commit 6dd466df.

:recycle: This comment has been updated with latest results.

codecov[bot] commented 8 months ago

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (d97de03) 71.52% compared to head (6dd466d) 71.36%. Report is 4 commits behind head on main.

Files Patch % Lines
src/zinolib/controllers/zino1.py 28.57% 5 Missing :warning:
src/zinolib/ritz.py 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #45 +/- ## ========================================== - Coverage 71.52% 71.36% -0.16% ========================================== Files 13 13 Lines 1366 1369 +3 ========================================== Hits 977 977 - Misses 389 392 +3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

hmpf commented 8 months ago

So, I suppose the RetryError is just a signal to the client code that it should attempt to retry the operation?

Yes. That's usually sufficient, though howitz actually counts these and can act on there being very many of them.

podliashanyk commented 8 months ago

I checked in Howitz and not all RetryErrors lead to automatic retry. Created a separate issue for it https://github.com/Uninett/Howitz/issues/62

podliashanyk commented 8 months ago

Garbage response from ZIno can often be emulated by setting f.e. poll_interval=5 and timeout=5 (some short time values in general) in Howitz config, and trying to expand multiple table rows while table polling request is ongoing.

hmpf commented 8 months ago

Should RetryError be raised on history fetch as well?

Not in this alpha :) The error has never happened for history fetch, for some reason.

sonarcloud[bot] commented 8 months ago

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud