Short tip: Updating Pulp database after upgrading Katello

After upgrading Katello recently, I stumbled upon the following error when accessing the administration interface:

Katello error message

The web server protocol told me that a database update might causes this issue:

1# tail /var/log/httpd/foreman-ssl_error_ssl.log
2[Wed Aug 17 09:42:51.536914 2016] [:error] [pid 3178] [remote] mod_wsgi (pid=3178): Target WSGI script '/usr/share/pulp/wsgi/webservices.wsgi' cannot be loaded as Python module.
3[Wed Aug 17 09:42:51.536946 2016] [:error] [pid 3178] [remote] mod_wsgi (pid=3178): Exception occurred processing WSGI script '/usr/share/pulp/wsgi/webservices.wsgi'.
4[Wed Aug 17 09:42:51.536960 2016] [:error] [pid 3178] [remote] Traceback (most recent call last):
5[Wed Aug 17 09:42:51.536971 2016] [:error] [pid 3178] [remote]   File "/usr/share/pulp/wsgi/webservices.wsgi", line 19, in <module>
6[Wed Aug 17 09:42:51.536993 2016] [:error] [pid 3178] [remote]     application = wsgi_application()
7[Wed Aug 17 09:42:51.537000 2016] [:error] [pid 3178] [remote]   File "/usr/lib/python2.7/site-packages/pulp/server/webservices/", line 117, in wsgi_application
8[Wed Aug 17 09:42:51.537010 2016] [:error] [pid 3178] [remote]     raise e
9[Wed Aug 17 09:42:51.537026 2016] [:error] [pid 3178] [remote] InitializationException: The database has not been migrated to the current version. Run pulp-manage-db and restart the application.

To update the Pulp database, it is necessary to run the pulp-manage-db utility as Apache user. This also requires changing the login shell temporarily:

 1# chsh -s /bin/bash apache
 2Changing shell for apache.
 3Shell changed.
 5# runuser -l apache -c pulp-manage-db
 6Attempting to connect to localhost:27017
 7Attempting to connect to localhost:27017
 8Write concern for Mongo connection: {}
 9Loading content types.
10Loading type descriptors []
11Parsing type descriptors
12Validating type descriptor syntactic integrity
13Validating type descriptor semantic integrity
15Database migrations complete.
17# chsh -s /sbin/nologin apache
18Changing shell for apache.
19Shell changed.

Afterwards, the user interface behaved like before.