Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kolibri fails to start if the timezone is detected incorrectly #7760

Closed
dylanmccall opened this issue Jan 25, 2021 · 0 comments · Fixed by #7761
Closed

Kolibri fails to start if the timezone is detected incorrectly #7760

dylanmccall opened this issue Jan 25, 2021 · 0 comments · Fixed by #7761
Labels
bug Behavior is wrong or broken

Comments

@dylanmccall
Copy link
Contributor

dylanmccall commented Jan 25, 2021

Observed behavior

In some environments, the time zone offset detected by tzlocal may not match the time zone offset of Python's time.localtime(). In that case, tzlocal's get_localzone() raises a ValueError exception: https://github.com/regebro/tzlocal/blob/c5282c6feded0d576937c0dcdf1f4fd00a95fbee/tzlocal/utils.py#L34-L46.

Expected behavior

It looks like Kolibri handles an UnknownTimeZoneError exception from pytz already. To solve this issue, we could handle the ValueError from tzlocal in the same way: https://github.com/learningequality/kolibri/blob/release-v0.14.x/kolibri/deployment/default/settings/base.py#L252-L257. (It is unfortunate that tzlocal throws such a generic exception here, but we probably need to put up with it).

User-facing consequences

At the moment, Kolibri is failing to start on Linux when using the America/Sao_Paulo timezone:

$ flatpak run org.learningequality.Kolibri 
WARNING:ifcfg:Neither `ifconfig` (`ifconfig -a`) nor `ip` (`ip address show`) commands are available, listing network interfaces is likely to fail
Process KolibriServiceMainProcess-1:
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/app/lib/python3.7/site-packages/kolibri_gnome/kolibri_service/kolibri_service_main.py", line 24, in run
    self.__run_kolibri_start()
  File "/app/lib/python3.7/site-packages/kolibri_gnome/kolibri_service/kolibri_service_main.py", line 49, in __run_kolibri_start
    initialize()
  File "/app/lib/python3.7/site-packages/kolibri/utils/cli.py", line 356, in initialize
    _setup_django()
  File "/app/lib/python3.7/site-packages/kolibri/utils/cli.py", line 293, in _setup_django
    django.setup()
  File "/app/lib/python3.7/site-packages/kolibri/dist/django/__init__.py", line 22, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/app/lib/python3.7/site-packages/kolibri/dist/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
  File "/app/lib/python3.7/site-packages/kolibri/dist/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/app/lib/python3.7/site-packages/kolibri/dist/django/conf/__init__.py", line 110, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/lib/python3.7/site-packages/kolibri_gnome/kolibri_settings.py", line 1, in <module>
    from kolibri.deployment.default.settings.base import *
  File "/app/lib/python3.7/site-packages/kolibri/deployment/default/settings/base.py", line 253, in <module>
    TIME_ZONE = get_localzone().zone
  File "/app/lib/python3.7/site-packages/kolibri/dist/tzlocal/unix.py", line 165, in get_localzone
    _cache_tz = _get_localzone()
  File "/app/lib/python3.7/site-packages/kolibri/dist/tzlocal/unix.py", line 90, in _get_localzone
    utils.assert_tz_offset(tz)
  File "/app/lib/python3.7/site-packages/kolibri/dist/tzlocal/utils.py", line 46, in assert_tz_offset
    raise ValueError(msg)
ValueError: Timezone offset does not match system offset: -7200 != -10800. Please, check your config files.
WARNING:kolibri_gnome.kolibri_service.kolibri_service_monitor:Kolibri service has died

(It appears Kolibri is including an old version of pytz which has incorrect information about DST for this timezone, but let's consider that tangential to this issue).

Steps to reproduce

Change your system timezone to "America/Sao_Paulo" and start Kolibri.

dylanmccall added a commit to dylanmccall/kolibri that referenced this issue Jan 25, 2021
dylanmccall added a commit to dylanmccall/kolibri that referenced this issue Jan 25, 2021
@jonboiser jonboiser added the bug Behavior is wrong or broken label Jan 25, 2021
dylanmccall added a commit to dylanmccall/org.learningequality.Kolibri that referenced this issue Feb 19, 2021
See also learningequality/kolibri#7760.

The dependency will be updated in Kolibri 0.14.7, but this change makes
this fix available for Kolibri users as soon as possible.
dylanmccall added a commit to dylanmccall/org.learningequality.Kolibri that referenced this issue Feb 19, 2021
See also learningequality/kolibri#7760.

The dependency will be updated in Kolibri 0.14.7, but this change makes
this fix available for Kolibri users as soon as possible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Behavior is wrong or broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants