zulip / docker-zulip

Container configurations, images, and examples for Zulip.
https://zulip.com/
Apache License 2.0
569 stars 235 forks source link

Investigate whether cron is broken in docker-zulip #173

Open timabbott opened 5 years ago

timabbott commented 5 years ago

See https://chat.zulip.org/#narrow/stream/2-general/subject/docker-zulip/near/670170 for the report; claim is it's a permissions issue.

jasonhildebrand commented 2 years ago

Cron doesn't seem completely broken, but doesn't work as expected, either. I'm trying to get inbound mail working using polling. I've confirmed my configuration is working (by running the job manually), and the last step is to install the cron job.

I am testing this by experimenting in my running container. I created this file in /etc/cron.d/test:

MAILTO=""
* * * * * /bin/bash -c "date >> /tmp/crontest"

but I get no output in /tmp/crontest. Maybe cron needs to be restarted? I killed it, and see from the output in /var/log/supervisor/supervisord.log that supervisord restarted it:

2022-02-14 03:28:16,571 INFO exited: cron (terminated by SIGTERM; not expected)
2022-02-14 03:28:17,575 INFO spawned: 'cron' with pid 3174
2022-02-14 03:28:18,578 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

But I still get no output in /tmp/crontest. On the other hand, it does seem to be executing the pre-installed job /etc/cron.d/update-analytics-counts which contains

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
USER=zulip

# Run update analytics tables every 5 minutes past the hour
5 * * * * zulip /home/zulip/deployments/current/manage.py update_analytics_counts

The evidence is in var/log/zulip/analytics.log, I see output each hour from the job:

2022-02-14 04:05:07,052 INFO     START messages_read_interactions::hour 2022-02-14 04:00:00+00:00
2022-02-14 04:05:07,057 INFO     messages_read_interactions::hour RealmCount aggregation (1ms/0r)
2022-02-14 04:05:07,059 INFO     messages_read_interactions::hour InstallationCount aggregation (0ms/0r)
2022-02-14 04:05:07,061 INFO     DONE messages_read_interactions::hour (8ms)
2022-02-14 04:05:07,077 INFO     Finished updating analytics counts through 2022-02-14 04:00:00+00:00

One major issue is that the zulip image has no syslog, so you can't tell what cron is doing. At my work we have dockerized several django apps. We use phusion/baseimage as our baseimage, which corrects numerous issues running stock ubuntu inside docker. Amongst other things, it includes working syslog and cron daemon.

If I have time I will rebuild the zulip image using phusion/baseimage to see if cron works normally. I expect swapping in a different baseimage won't be seamless, though, so this could be a deep dive.