aws-cloudformation / aws-cloudformation/aws-cloudformation-templates

cfn-hup in daemon mode doesn't work on any currently supported Python version, because of dependency on obsolete python-daemon version

Open
#392 11 comments 1 reaction 0 assignees View on GitHub
bug keep
Dominant language
Python
Stars
5.2k
Forks
4.6k
PR merge metrics
No merged PRs in 30d

Description

`aws-cfn-bootstrap` requires `python-daemon<2.2`, but version 2.2.4 (from 2019) is the oldest version that supports Python 3.8+. Thus, any OS with a current version of Python (eg 3.10 in Ubuntu 22.04) will get the following error when attempting to launch `cfn-hup` in daemon mode:

```
Traceback (most recent call last):
File "/usr/local/bin/cfn-hup", line 226, in
with daemon.DaemonContext(pidfile=pidfile.TimeoutPIDLockFile('/var/run/cfn-hup.pid', 300),
File "/usr/local/lib/python3.10/dist-packages/daemon/daemon.py", line 280, in __init__
detach_process = is_detach_process_context_required()
File "/usr/local/lib/python3.10/dist-packages/daemon/daemon.py", line 801, in is_detach_process_context_required
if is_process_started_by_init() or is_process_started_by_superserver():
File "/usr/local/lib/python3.10/dist-packages/daemon/daemon.py", line 778, in is_process_started_by_superserver
if is_socket(stdin_fd):
File "/usr/local/lib/python3.10/dist-packages/daemon/daemon.py", line 743, in is_socket
file_socket = socket.fromfd(fd, socket.AF_INET, socket.SOCK_RAW)
File "/usr/lib/python3.10/socket.py", line 546, in fromfd
return socket(family, type, proto, nfd)
File "/usr/lib/python3.10/socket.py", line 232, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 88] Socket operation on non-socket
```

Ignoring the dependency error and forcing a newer `python-daemon` version seems to lead to `cfn-hup` silently failing, which I've not investigated further, so currently the best workaround I know of is to run it with `--no-daemon` in a cronjob or systemd timer.

Contributor guide

Open the contributing guide

Research direction

Start at the cfn-hup entry point and inspect how daemon mode uses the python-daemon dependency. Reproduce the failure on a currently supported Python version, then verify that cfn-hup can launch in daemon mode without the socket error or silent failure; the issue names no repository test to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.