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

Crash if /etc/timezone is a directory #5365

Closed
beci opened this issue Jan 25, 2022 · 3 comments
Closed

Crash if /etc/timezone is a directory #5365

beci opened this issue Jan 25, 2022 · 3 comments

Comments

@beci
Copy link

beci commented Jan 25, 2022

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"
}
}

@zanieb
Copy link
Contributor

zanieb commented Jan 25, 2022

Hey @beci — I'm not sure what we could do to resolve this for you since this is an upstream bug in pendulum. You can install pendulum from git instead of PyPi so you don't have to wait for a release e.g.

pip install git+https://github.com/sdispater/pendulum@master

@beci
Copy link
Author

beci commented Jan 25, 2022

I'm afraid you can't do too much until that pendulum fix is released. I opened this issue to notify you about the problem and save some time for the ones who experience the same problem.

@zanieb
Copy link
Contributor

zanieb commented Jan 25, 2022

Thanks! I'm sure it'll be helpful. Since we can't do anything, I'm going to close the issue. Changing your pendulum installation if you're affected should be a viable workaround.

@zanieb zanieb closed this as completed Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants