open-bus icon indicating copy to clipboard operation
open-bus copied to clipboard

siri requester should have better error handling and retry mechanism in case source data is not available

Open OriHoch opened this issue 3 years ago • 3 comments

currently, if source data is not available, siri requester daemon exits with exception and the pod enters a restart loop until it gives up

need to have better handling of this, so it retries until we get a response

Traceback (most recent call last):
  File "/usr/local/bin/open-bus-siri-requester", line 33, in <module>
    sys.exit(load_entry_point('open-bus-siri-requester', 'console_scripts', 'open-bus-siri-requester')())
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/srv/open_bus_siri_requester/cli.py", line 56, in daemon_start
    daemon.start()
  File "/srv/open_bus_siri_requester/daemon.py", line 46, in start
    run_single_iteration(now, last_cleanup_datetime)
  File "/srv/open_bus_siri_requester/daemon.py", line 19, in run_single_iteration
    snapshot_id = store_callback(requester_callback(), now, upload=True)
  File "/srv/open_bus_siri_requester/requester.py", line 45, in request
    return requests.get(
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

OriHoch avatar Jan 18 '22 09:01 OriHoch

in case siri source is not available we should try the "test" source - see comment - https://github.com/hasadna/open-bus/issues/367#issuecomment-1015423458

OriHoch avatar Jan 18 '22 13:01 OriHoch

additional info from MOT:

בשלב הזה, אני מציע, שתבצעו ניסיון נוסף רק על מקרה של סטטוס http שגוי מסביבת הייצור

אכן המקרה של תשובה ריקה אינו טרווילי, אם כי גם לזה אפשר לנסות לתת מענה.

בתשובה של snapshot יש

"ResponseTimestamp":"2021-10-12T13:38:30+03:00"

אם הזמן שמתקבל הוא נניח יותר משתי דקות, אז זה אומר שלא בוצע תהליך יצירה של מידע חדש, ואז אפשר לבצע ניסיון לפניה לסביבת הייצור.

צריך לקחת בחשבון, שלמערכת שלנו יש לא רק השבתות אלא גם תקלות. שתי הבדיקות והללו וניסיון נוסף למול סביבת הבדיקות יעלה את זמינות המערכת מאוד.

OriHoch avatar Jan 19 '22 12:01 OriHoch

fixed in hasadna/open-bus-siri-requester#5

OriHoch avatar Feb 09 '22 12:02 OriHoch