Commit Graph

46889 Commits

Author SHA1 Message Date
Anders Kaseorg
1593ab6082 install: Resupport Ubuntu 22.04.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit e952641013)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
3bc1ad05f7 zulip-puppet-apply: Work around broken Puppet on Ubuntu 22.04.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 25c87cc7da)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
e124464fea requirements: Upgrade to Tornado 6.
Fixes #8913.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 7acb642fa5)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
9362158e04 run-dev: Fix types.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit f23bfe91c0)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
0ccc706f7a runtornado: Switch to asyncio event loop.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 6fd1a558b7)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
b4a0684201 queue: Use a thread-local Pika connection.
According to the documentation: “Pika does not have any notion of
threading in the code. If you want to use Pika with threading, make
sure you have a Pika connection per thread, created in that thread. It
is not safe to share one Pika connection across threads, with one
exception: you may call the connection method add_callback_threadsafe
from another thread to schedule a callback within an active pika
connection.”

https://pika.readthedocs.io/en/stable/faq.html

This also means that synchronous Django code running in Tornado will
use its own synchronous SimpleQueueClient rather than sharing the
asynchronous TornadoQueueClient, which is unfortunate but necessary as
they’re about to be on different threads.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit c263bfdb41)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
ad9187d9f7 cache: Instantiate only one BMemcached cache backend.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit c9faefd50e)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
edda368670 requirements: Upgrade asgiref.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 52b9c59875)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
f7f750e7a8 run-dev: Switch to asyncio event loop.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 0ef9309e92)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
ce8d8f3846 runtornado: Avoid deprecated IOLoop debugging methods.
IOLoop.set_blocking_log_threshold and IOLoop.handle_callback_exception
are removed in Tornado 6.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 5d69dafddb)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
d632e2c6bf tornado: Remove instrument_tornado_ioloop.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit e4bf7066f3)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
ac5e31ce04 tornado: Unfork tornado.autoreload.
We previously forked tornado.autoreload to work around a problem where
it would crash if you introduce a syntax error and not recover if you
fix it (https://github.com/tornadoweb/tornado/issues/2398).

A much more maintainable workaround for that issue, at least in
current Tornado, is to use tornado.autoreload as the main module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit bded7180f7)
2022-05-16 12:05:23 -07:00
Anders Kaseorg
5f474e8425 run-dev: Avoid deprecated tornado.gen.engine.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 1c7954b452)
2022-05-16 12:05:23 -07:00
Alex Vandiver
33d43b695e docs: Clarify nginx extension points.
(cherry picked from commit 04d4ae9862)
2022-05-10 14:57:11 -07:00
Alex Vandiver
acf90db8b6 docs: Update proxy docs.
Notable changes:
 - Describe `X-Forwarded-For` by name.
 - Switch each specific proxy to numbered steps.
 - Link back to the `X-Forwarded-For` section in each proxy
 - Default to using HTTPS, not HTTP, for the backend.
 - Include the HTTP-to-HTTPS redirect code for all proxies; it is
   important that it happen at the proxy, as the backend is unaware of
   it.
 - Call out Apache2 modules which are necessary.
 - Specify where the dhparam.pem file can be found.
 - Call out the `Host:` header forwarding necessary, and document
   `USE_X_FORWARDED_HOST` if that is not possible.
 - Standardize on 20 minutes of connection timeout.
2022-05-04 14:44:11 -07:00
Alex Vandiver
40968fda49 settings: Stop enabling USE_X_FORWARDED_HOST by default.
This was added in 1fded25025, and is not
necessary for standard Zulip installs.  While both Host: and
X-Forwarded-Host: are nominally untrusted, there is no reason to
complicate the deployment by defaulting it on.
2022-05-04 14:44:11 -07:00
Alex Vandiver
4b3f68382c version: Update version after 5.2 release. 2022-05-03 18:00:50 -07:00
Alex Vandiver
b20797ed9c Release Zulip Server 5.2. 5.2 2022-05-04 00:27:55 +00:00
Alex Vandiver
e637ff626d version: Fix latest major version and blog post link. 2022-05-04 00:27:08 +00:00
Alex Vandiver
ca4cf94e79 settings: Remove misleading and irrelevant comment.
This comment was _originally_ for the `default` memcached cache, back
when it was added all of the way back in 0a84d7ac62.  9e64750083
made it a lie, and edc718951c made it even more confusing when it
removed the `default` cache configuration block, leaving the wrong
comment next to the wrong cache configuration block.

Banish the comment.

(cherry picked from commit 7cc9b93b91)
2022-05-03 16:12:08 -07:00
Alex Vandiver
789e960672 test_link_embed: Remove unnecessary TEST_CACHES.
The only purpose of this seems to be to not have to reset the cache;
fae59502ab added it without any explanation for why it is necessary.

Remove it, and explicitly flush the cache in the one place where it is
necessary.

(cherry picked from commit 9030d53acb)
2022-05-03 16:12:08 -07:00
Alex Vandiver
572138d983 caches: Remove unnecessary "in-memory" cache.
This cache was added in da33b72848 to serve as a replacement for the
durable database cache, in development; the previous commit has
switched that to be the non-durable memcached backend.

The special-case for "in-memory" in development is mostly-unnecessary
in contrast to memcached -- `./tools/run-dev.py` flushes memcached on
every startup.  This differs in behaviour slightly, in that if the
codepath is changed and `run-dev` restarts Django, the cache is not
cleared.  This seems an unlikely occurrence, however, and the code
cleanup from its removal is worth it.

(cherry picked from commit 56058f3316)
2022-05-03 16:12:08 -07:00
Alex Vandiver
df8ac69d90 caches: Cache link preview data in memcached, not in PostgreSQL.
The choice to cache these in the database dates back to c93f1d4eda,
with the comment added in da33b72848 while working around the
durability of the "database" cache in local development.

The values were stored in a durable cache, as they needed to be
ensured to persist between when they were inserted in
`get_link_embed_data` and when they were used in
`render_incoming_message` via `link_embed_data_from_cache`.

However, database accesses are not fast compared to memcached, and we
wish to avoid the overhead of the database connection from the
`embed_links` worker.  Specifically, making the connection may not be
thread-safe -- and in low-memory (and Docker) configurations, all
workers run as separate threads in a single process.  This can lead to
stalled database connections in `embed_links` workers, and failed
previews.

Since the previous commit made the durability of the cache no longer
necessary, this will have minimal effect; at worst, posting the same
URL twice, on either side of an upgrade, will result in two preview
fetches of it.

(cherry picked from commit 04ca2e92f7)
2022-05-03 16:12:08 -07:00
Alex Vandiver
9a9c6730ff preview: Use cache only as a non-durable cache, not an IPC.
The `get_link_embed_data` / `link_embed_data_from_cache` pair as
introduced in c93f1d4eda uses the cache
as a temporary store inside of the `embed_links` worker; this means
that it must be durable storage, or the worker will stall and re-fetch
the same links to preview them.

Switch to plumbing through the fetched URL embed data as an parameter
to the Markdown evaluation which uses them, rather than using the
cache as an intermediary.  This frees up the cache to be merely a
non-durable cache.

As a side-effect, this removes get_cache_with_key, and
link_embed_data_from_cache which was its only callsite.

(cherry picked from commit 351bdfaf78)
2022-05-03 16:12:04 -07:00
Alex Vandiver
5ff82c82ae preview: Use a dataclass for the embed data.
This is significantly cleaner than passing around `Dict[str, Any]` all
of the time.

(cherry picked from commit 327ff9ea0f)
2022-05-03 16:10:25 -07:00
Alex Vandiver
00b3da0a0c populate_db: Remove unnecessary pre-population of URL cache.
76deb30312 changed this to not just be the URL, but rather a
prefixed hash of the URL, but failed to update this location which
wrote to it.  This meant that this pre-population step was writing to
the wrong keys in the durable cache, and thus ineffective.

Then, da33b72848 switched the cache to be in-memory, making this
write to the wrong keys in an in-process memory store.  There is no
way to pre-fill this sort of cache, except at server start-up.

Finally, and most fundamentally, 8c0c9ca7a4 then disabled
`inline_url_embed_preview` by default, making the code entirely moot.

Remove the triply-unnecessary code.

(cherry picked from commit ede4a88b49)
2022-05-03 16:10:25 -07:00
Alex Vandiver
9ded5be2a7 cache: Make the cache_name=None behaviour clearer.
`django.core.cache.cache` is equal to
`django.core.cache.caches["default"]`; the latter is more
understandable in context.

(cherry picked from commit aaa58a49db)
2022-05-03 16:10:25 -07:00
Alex Vandiver
0d0aaf3c92 markdown: Use named parameters to add_a helper.
This has enough parameters that it benefits from making which is which
explicit.

(cherry picked from commit 661c333377)
2022-05-03 16:10:24 -07:00
Alex Vandiver
26907e1c2e markdown: Clarify url parameter of "add_a" helper.
(cherry picked from commit 452a30305d)
2022-05-03 16:10:24 -07:00
Aman Agrawal
953f3c8c1d resize: Don't use visible selector to find element states.
This change decreases the time required to open compose
after clicking a message. The amount of time reduced varies with pc.

The time reduction was around 0.4s to 0.6s for me after using a
6x CPU slowdown. This may not sound convincing but the profile
uploaded in #21979 clearly shows the root cause of having a message
click take 10s was the `:visible` query.

Fixes #21979
2022-05-03 09:36:32 -07:00
Alex Vandiver
abf82392a3 puppet: Fix non-replicated PostgreSQL 10 and 11 configuration.
6f5ae8d13d removed the `$replication` variable from the
configurations of PostgreSQL 12 and higher, but left it in the
templates for PostgreSQL 10 and 11.  Because `undef != ''`,
deployments on PostgreSQL 10 and 11 started trying to push to S3
backups, regardless of if they were configured, leaving frequent log
messages like:

```
2022-04-30 12:45:47.805 UTC [626d24ec.1f8db0]: [107-1] LOG: archiver process (PID 2086106) exited with exit code 1
2022-04-30 12:45:49.680 UTC [626d24ee.1f8dc3]: [18-1] LOG: checkpoint complete: wrote 19 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=1.910 s, sync=0.022 s, total=1.950 s; sync files=16, longest=0.018 s, average=0.002 s; distance=49 kB, estimate=373 kB
/usr/bin/timeout: failed to run command "/usr/local/bin/env-wal-g": No such file or directory
2022-04-30 12:46:17.852 UTC [626d2f99.1fd4e9]: [1-1] FATAL: archive command failed with exit code 127
2022-04-30 12:46:17.852 UTC [626d2f99.1fd4e9]: [2-1] DETAIL: The failed archive command was: /usr/bin/timeout 10m /usr/local/bin/env-wal-g wal-push pg_wal/000000010000000300000080
```

Switch the PostgreSQL 10 and 11 configuration to check
`s3_backups_bucket`, like the other versions.

(cherry picked from commit d891b9590a)
2022-05-02 17:58:27 -07:00
Alex Vandiver
fb9cdf0f56 compare-settings-to-template: Handle prod_settings_template renaming.
(cherry picked from commit 3476f63dca)
2022-04-28 15:46:22 -07:00
Alex Vandiver
df80303a64 compare-settings-to-template: Simplify and dedent logic.
(cherry picked from commit b6b6faa404)
2022-04-28 15:46:22 -07:00
Alex Vandiver
d7fb2292eb compare-settings-to-template: Fetch 100 per pagination.
(cherry picked from commit d205050ab0)
2022-04-28 15:46:22 -07:00
Alex Vandiver
827d1d9d3b compare-settings-to-template: Paginate through all tags.
The default page size is 30, which means this only goes back to 4.6 at
present, due to starting with `shared-...` and old `enterprise-...`
tags.

(cherry picked from commit d79776f80d)
2022-04-28 15:46:22 -07:00
Alex Vandiver
64b563e1dc prod_settings_template: Switch to double quotes in commented lines. 2022-04-28 12:40:52 -07:00
Alex Vandiver
92fdfffa4d prod_settings_template: Add some missing quotes in commented lines. 2022-04-28 12:40:50 -07:00
Alex Vandiver
1767a0bcb1 puppet: Check that certbot certs are in use before fixing them.
It is possible to have previously installed certbot, but switched back
to using self-signed certificates -- in which case renewing them using
certbot may fail.

Verify that the certificate is a symlink into certbot's output
directory before running `fix-standalone-certbot`.

(cherry picked from commit c97162e485)
2022-04-28 00:53:56 -07:00
Anders Kaseorg
6736b35f5f puppet: ‘supervisorctl stop all’ before restarting Supervisor.
This fixes a failure of the 3.4 upgrade test running on Ubuntu 20.04
with Supervisor 4.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit a7e6cb7705)
2022-04-27 12:15:07 -07:00
Mateusz Mandera
c34110f88c digest: Don't send emails to deactivated users, even if queued. 2022-04-15 14:33:16 -07:00
Mateusz Mandera
fc4102d779 test_digest: Fix typo in a comment. 2022-04-15 14:33:15 -07:00
Anders Kaseorg
4d0ddf483d actions: Delete zerver.lib.actions.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit cc30ed8ec7)
2022-04-15 10:08:19 -07:00
Anders Kaseorg
9c927e40d6 actions: Move part into zerver.lib.test_classes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 729019acdd)
2022-04-15 10:08:19 -07:00
Anders Kaseorg
4d21bad033 actions: Split out zerver.actions.create_realm.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit e01faebd7e)
2022-04-15 10:08:19 -07:00
Anders Kaseorg
472428621a actions: Split out zerver.actions.realm_domains.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 53f4a395bc)
2022-04-15 10:08:19 -07:00
Anders Kaseorg
37b40df30c actions: Split out zerver.actions.realm_settings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 59f6b090c7)
2022-04-15 10:08:19 -07:00
Anders Kaseorg
87c58f8e23 actions: Move part into zerver.forms.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 12de8d797e)
2022-04-15 10:08:19 -07:00
Anders Kaseorg
eb5832f7a4 actions: Split out zerver.actions.message_edit.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit eda000899b)
2022-04-15 10:08:19 -07:00
Anders Kaseorg
a9b6d9990a actions: Split out zerver.actions.muted_users.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 5d1a5a3877)
2022-04-15 10:08:19 -07:00
Anders Kaseorg
f4fe1660f3 actions: Split out zerver.actions.bots.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit ec174dfb47)
2022-04-15 10:08:19 -07:00