Bug 46532 - ucsschool43 HTTP-API import: stretch dropped gunicorn start script
ucsschool43 HTTP-API import: stretch dropped gunicorn start script
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: HTTP-API (Kelvin)
UCS@school 4.3
Other Linux
: P5 normal (vote)
: UCS@school 4.3 v1
Assigned To: Daniel Tröder
Sönke Schwardt-Krummrich
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-03-07 15:42 CET by Daniel Tröder
Modified: 2018-03-14 13:11 CET (History)
0 users

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.086
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
systemd unit file (497 bytes, text/plain)
2018-03-07 16:00 CET, Daniel Tröder
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2018-03-07 15:42:58 CET
Debian Stretch dropped gunicorn start scripts. Gunicorn must run for the HTTP-API.

From /usr/share/doc/gunicorn/NEWS.Debian.gz:

gunicorn (19.6.0-3) unstable; urgency=medium

  The /etc/gunicorn.d (and related usr/sbin/gunicorn{,3}-debian) scripts were
  removed in 19.6.0-3 due to inflexibility, lack of documentation, not
  adopted/supported upstream, did not work with virtualenvs, etc.

  They were dropped prior to the stretch release to avoid having to support it
  for another full release.

  Users relying on this feature should invoke gunicorn manually. For an example
  systemd .service file, please see the ``gunicorn-mysite.service`` file in the
  gunicorn-examples package or a process manager such as runit, etc.
Comment 1 Daniel Tröder univentionstaff 2018-03-07 16:00:18 CET
Created attachment 9445 [details]
systemd unit file

This seems to work.
(Tested by putting it directly into /lib/systemd/system/, no packaging done.)
Comment 2 Daniel Tröder univentionstaff 2018-03-08 18:38:02 CET
[4.3 3f5796db] Bug #46532: create systemd service unit for gunicorn

ucs-school-import (16.0.1-6)
Comment 3 Daniel Tröder univentionstaff 2018-03-09 11:07:20 CET
DB migrations are missing.
Comment 4 Daniel Tröder univentionstaff 2018-03-09 11:08:31 CET
(In reply to Daniel Tröder from comment #3)
> DB migrations are missing.
Wrong bug (should have been Bug #46533).
Comment 5 Sönke Schwardt-Krummrich univentionstaff 2018-03-11 23:06:14 CET
(OK): code change (service file is ok; commit is incomplete; see below)
OK: functional change
OK: tests (gunicorn + celery are running after installation)


From service file:
> ExecStart=/usr/bin/gunicorn --workers=4 --bind=127.0.0.1:8000 --timeout=60 \
  ucsschool.http_api.app.wsgi:application --name ucs-school-import --user root \
  --group root

What timeout is exactly meant by "--timeout"? The command line help is not very specific?

> -t INT, --timeout INT
>                         Workers silent for more than this many seconds are
>                         killed and restarted. [30]

Does this mean, that long-running imports that take longer than 60 seconds are killed by gunicorn?
→ REOPEN

During installation:
[...]
Joinscript 40ucs-school-import-http-api.inst finished with exitcode 0
celery-worker-ucsschool-import.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install is-enabled celery-worker-ucsschool-import
Failed to get unit file state for gunicorn.service: No such file or directory
gunicorn.service is a disabled or a static unit not running, not starting it.
Trigger für python-support (1.0.15.18.201403132013) werden verarbeitet ...
[...]

--- a/ucs-school-import/debian/ucs-school-import-http-api.postinst
+++ b/ucs-school-import/debian/ucs-school-import-http-api.postinst
@@ -43,7 +43,7 @@ univention-config-registry set ucsschool/import/generate/import/group?true
 call_joinscript 40ucs-school-import-http-api.inst
 
 systemctl daemon-reload
-for SERVICE in  rabbitmq-server celery-worker-ucsschool-import postgresql gunicorn apache2;
+for SERVICE in  rabbitmq-server celery-worker-ucsschool-import postgresql ucs-school-import-http-api apache2;
 do
     deb-systemd-invoke restart "$SERVICE.service"
 done

Applied this patch and a similar patch to the join script to test the installation.

Package: ucs-school-import
Version: 16.0.1-9A~4.3.0.201803112249
Branch: ucs_4.3-0
Scope: ucs-school-4.3
Comment 6 Daniel Tröder univentionstaff 2018-03-12 08:10:35 CET
(In reply to Sönke Schwardt-Krummrich from comment #5)
> From service file:
> > ExecStart=/usr/bin/gunicorn --workers=4 --bind=127.0.0.1:8000 --timeout=60 \
>   ucsschool.http_api.app.wsgi:application --name ucs-school-import --user
> root \
>   --group root
> 
> What timeout is exactly meant by "--timeout"? The command line help is not
> very specific?
> 
> > -t INT, --timeout INT
> >                         Workers silent for more than this many seconds are
> >                         killed and restarted. [30]
> 
> Does this mean, that long-running imports that take longer than 60 seconds
> are killed by gunicorn?
> → REOPEN
It does indeed mean, that requests that take longer than 60s will be aborted with HTTP 50x (probably 502 or 504). The import job is however not run by Gunicorn, but by a Celery worker.
IMHO we could remove the timeout completely / lower it to its default of 30s, as it is only relevant during dry-run, but there AJAX keeps making a new connection every second. But in the spirit of a quick QA, I don't change the package now.
Comment 7 Sönke Schwardt-Krummrich univentionstaff 2018-03-12 21:59:07 CET
(In reply to Daniel Tröder from comment #6)
> (In reply to Sönke Schwardt-Krummrich from comment #5)
> > Does this mean, that long-running imports that take longer than 60 seconds
> > are killed by gunicorn?
> > → REOPEN
> It does indeed mean, that requests that take longer than 60s will be aborted
> with HTTP 50x (probably 502 or 504). The import job is however not run by
> Gunicorn, but by a Celery worker.
→ OK

> IMHO we could remove the timeout completely / lower it to its default of
> 30s, as it is only relevant during dry-run, but there AJAX keeps making a
> new connection every second. But in the spirit of a quick QA, I don't change
> the package now.
→ :-) I really appreciate this move.
Comment 8 Sönke Schwardt-Krummrich univentionstaff 2018-03-14 13:11:56 CET
UCS@school 4.3 v1 has been released.

https://docs.software-univention.de/release-notes-ucsschool-4.3v1-de.html

If this error occurs again, please clone this bug.