From 0645656fd8d4221ee35c4619aa2fdff8ef5d90c5 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Thu, 16 Jun 2022 12:01:05 -0700 Subject: [PATCH] process_fts_updates: Nagios may lack permissions to load Django config. Even if Django and PostgreSQL are on the same host, the `nagios` user may lack permissions to read accessory configuration files needed to load the Django configuration (e.g. authentication keys). Catch those failures, and switch to loading the required settings from `/etc/zulip/zulip.conf`. --- puppet/zulip/files/postgresql/process_fts_updates | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/puppet/zulip/files/postgresql/process_fts_updates b/puppet/zulip/files/postgresql/process_fts_updates index ac2946474d..722307c776 100755 --- a/puppet/zulip/files/postgresql/process_fts_updates +++ b/puppet/zulip/files/postgresql/process_fts_updates @@ -29,6 +29,10 @@ # however, we wish to import `zerver.settings` since we have no # /etc/zulip/zulip.conf to read, and that case _requires_ loading the # venv. +# +# We also must handle the cases where we are run as the `nagios` user, +# which may not have permission to read all configuration files, and +# thus (2) will look like (3). import argparse import configparser @@ -134,7 +138,7 @@ try: pg_args["sslmode"] = settings.DATABASES["default"]["OPTIONS"].get("sslmode") pg_args["connect_timeout"] = "600" USING_PGROONGA = settings.USING_PGROONGA -except ImportError: +except (ImportError, PermissionError): # Case (3): we know that the PostgreSQL server is on this host. pg_args["user"] = "zulip"