Skip to content

Crash if /etc/timezone is a directory #5365

@beci

Description

@beci

Description

If the /etc/timezone is a directory, then prefect crashes.
Yes, that should be a file (link) instead of a folder, but some distribution and package maintainers like to create it on every update. I'm using a few ArchLinux machines, where this happens after every update.

This is caused by a bug in pendulum which is fixed by me already. Even if the fix is already merged, I don't know when it will be released, so this is the reason for this issue. I hope for the best because it's also affecting airflow.

Expected Behavior

...

Reproduction

  • safely move your /etc/timezone to a backup place to easy to restore later sudo mv /etc/timezone /etc/timezone.backup if exists
  • create /etc/timezone as directory sudo mkdir /etc/timezone
  • do something, like start an agent prefect agent local start --name "Temp agent"
prefect agent local start --name "Temp agent"
Traceback (most recent call last):
  File "/home/beci/.local/bin/prefect", line 8, in <module>
    sys.exit(cli())
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/beci/.local/lib/python3.10/site-packages/prefect/cli/agent.py", line 182, in start
    start_agent(LocalAgent, import_paths=list(import_paths), **kwargs)
  File "/home/beci/.local/lib/python3.10/site-packages/prefect/cli/agent.py", line 139, in start_agent
    agent = agent_cls(labels=labels, env_vars=env_vars, **kwargs)
  File "/home/beci/.local/lib/python3.10/site-packages/prefect/agent/local/agent.py", line 77, in __init__
    super().__init__(
  File "/home/beci/.local/lib/python3.10/site-packages/prefect/agent/agent.py", line 134, in __init__
    self.client = Client(api_server=config.cloud.api, api_token=token)
  File "/home/beci/.local/lib/python3.10/site-packages/prefect/client/client.py", line 122, in __init__
    self._access_token_expires_at = pendulum.now()
  File "/home/beci/.local/lib/python3.10/site-packages/pendulum/__init__.py", line 211, in now
    dt = _datetime.datetime.now(local_timezone())
  File "/home/beci/.local/lib/python3.10/site-packages/pendulum/tz/__init__.py", line 60, in local_timezone
    return get_local_timezone()
  File "/home/beci/.local/lib/python3.10/site-packages/pendulum/tz/local_timezone.py", line 35, in get_local_timezone
    tz = _get_system_timezone()
  File "/home/beci/.local/lib/python3.10/site-packages/pendulum/tz/local_timezone.py", line 63, in _get_system_timezone
    return _get_unix_timezone()
  File "/home/beci/.local/lib/python3.10/site-packages/pendulum/tz/local_timezone.py", line 165, in _get_unix_timezone
    with open(tzpath, "rb") as tzfile:
IsADirectoryError: [Errno 21] Is a directory: '/etc/timezone'

Environment

prefect diagnostics
{
"config_overrides": {},
"env_vars": [],
"system_information": {
"platform": "Linux-5.16.0-arch1-1-x86_64-with-glibc2.33",
"prefect_backend": "server",
"prefect_version": "0.15.11",
"python_version": "3.10.1"
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions