netFIELD App Edge Monitor does not work on Fedora 35 due to missing /etc/timezone

Q

netFIELD App Edge Monitor does not work on Fedora 35 due to missing /etc/timezone

A

Description and identification

  • netFIELD App Edge Monitor container crashes some seconds after start, stuck in a restart loop
    • does not publish any messages to the MQTT broker
    • related log records written by the container
      • Traceback (most recent call last):
        File "index.py", line 370, in <module>
        scheduler.add_job(
        File "/root/.local/lib/python3.8/site-packages/apscheduler/schedulers/base.py", line 420, in add_job
        'trigger': self._create_trigger(trigger, trigger_args),
        File "/root/.local/lib/python3.8/site-packages/apscheduler/schedulers/base.py", line 921, in _create_trigger
        return self._create_plugin_instance('trigger', trigger, trigger_args)
        File "/root/.local/lib/python3.8/site-packages/apscheduler/schedulers/base.py", line 906, in _create_plugin_instance
        return plugin_cls(**constructor_kwargs)
        File "/root/.local/lib/python3.8/site-packages/apscheduler/triggers/interval.py", line 38, in __init__
        self.timezone = astimezone(timezone)
        File "/root/.local/lib/python3.8/site-packages/apscheduler/util.py", line 86, in astimezone
        raise ValueError(
        ValueError: Unable to determine the name of the local timezone -- you must explicitly specify the name of the local timezone. Please refrain from using timezones like EST to prevent problems with daylight saving time. Instead, use a locale based timezone name
        (such as Europe/Helsinki).

Analysis

The netFIELD App Edge Monitor application retrieves the timezone from the /etc/timezone file. The create options include a bind mount "/etc/timezone:/etc/timezone" to share the configured host timezone with the container.

Fedora 35 does not use /etc/timezone to store the configured timezone, the file does not even exist. The timezone info is available following the symlink /etc/localtime is pointing to.


[iot-test@tst-nfexts-6953-fedora35 ~]$ ls -lh /etc/timezone
ls: cannot access '/etc/timezone': No such file or directory
[iot-test@tst-nfexts-6953-fedora35 ~]$ ls -lh /etc/localtime
lrwxrwxrwx. 1 root root 35 Apr  5 08:27 /etc/localtime -> ../usr/share/zoneinfo/Europe/Berlin

Workaround

Generate a /etc/timezone file reflecting the currently set timezone:

  • (warning) this will not be automatically updated when changing the timezone, "snapshots" the currently set timezone and writes it to /etc/timezone
  • sudo rm -rf /etc/timezone; timedatectl show | grep Timezone | awk -F '=' '{print $2}' | sudo tee /etc/timezone
    • note:  due to the bind-mount used by netFIELD App Edge Monitor, there will be an auto-created directory /etc/timezone/ after deploying the container
    • example result:
      • [iot-test@tst-nfexts-6953-fedora35 ~]$ cat /etc/timezone
        Europe/Berlin
        [iot-test@tst-nfexts-6953-fedora35 ~]$ ls -lh /etc/localtime
        lrwxrwxrwx. 1 root root 35 Apr  5 08:27 /etc/localtime -> ../usr/share/zoneinfo/Europe/Berlin