Commit Graph

3659 Commits

Author SHA1 Message Date
Luke Faraone a59d5b9ce6 Use 'Python API' as the API client string
(imported from commit 5c1f8a9c089aaed1c82729f81819b8373d796c2a)
2013-03-28 07:53:37 -07:00
Luke Faraone bfb741c9bb Factor out client extraction and API key validation from authenticated_api_view
(imported from commit b8e3fc2f956b4de07ea0fe9b6f596dd353013935)
2013-03-28 07:53:36 -07:00
Luke Faraone b63e5e3235 Refactor runtorando AsyncDjangoHandler URLs into a list.
(imported from commit f5c65f69dd2ccb5a0ba6339b28b8c486cde2c7ff)
2013-03-28 07:53:36 -07:00
Luke Faraone 2be8f80f47 Make request._client a public member, dropping the '_'.
(imported from commit 5fc7ab57157ceb40c8bca9b0c97a47d8fac6745b)
2013-03-28 07:53:36 -07:00
Luke Faraone 9519484c8f Remove 'client' paramater from update_user_activity
(imported from commit 906bf35c1b6d056170bdf3472146e38dabce53bb)
2013-03-28 07:53:35 -07:00
Luke Faraone b6ed350c55 Remove explicit "client" parameter from send_message_backend.
Instead we now rely on the request._client value, which we were previously
passing along to s_m_b in all but one case.

For that one case, we just modify the Request object to include the value
beforehand.

(imported from commit 542f38f94bc447149cd4d2efaa5e8f48f756725b)
2013-03-28 07:53:34 -07:00
Luke Faraone fc2a071314 Scroll subscription settings into view on click.
Addresses a complaint brought up in our usability study.

We now hook into the "show" event on .subscription_settings elements and
do some obnoxious math to move the scrollbar the way we want.

Closes trac #1015.

(imported from commit 5d9cee1ffc242eb7b743fdccd2bd76bf0a7ba060)
2013-03-28 07:50:49 -07:00
Tim Abbott 78f5c2e877 Use the update_fields option to Django ORM .save().
This can result in a significant performance benefit because we only
need to update the columns that changed..

(imported from commit 42bef1fcc58ad79bd864f89263fe82e90743ee5b)
2013-03-28 07:36:11 -04:00
Tim Abbott 7b968cd088 Revert "Revert "to_dict: Update rendered_content in the database after rendered.""
This reverts commit 745b4a98d0e3f67acaa207ba53e9250060dcfe06.

(imported from commit ea59de391b93b82b08c35d92620d7d8ae263f34d)
2013-03-28 07:36:10 -04:00
Tim Abbott dc64345c8c puppet: Add TODO item for Django 1.5 being installed on frontends.
(imported from commit b4a884036d8050e2ecb780ce5779997ffce3a7b8)
2013-03-28 07:36:10 -04:00
Tim Abbott 7103c4df59 puppet: Ensure Python 2.5 is not installed.
Django 1.5 won't install if Python 2.5 is installed.

(imported from commit 949b81b6456b0dff4f5d11f0a9d8c7018605c492)
2013-03-28 07:36:10 -04:00
Tim Abbott a4383f8264 Remove batch_bulk_create helper function.
The behavior we require is now standard in Django 1.5.

(imported from commit 509adb0bd371081a2dad7d4a04d24fcffbda7cdc)
2013-03-28 07:36:10 -04:00
Tim Abbott e8aa77c9b4 Set timeouts for our memcached caches.
The policy this implements is:
* 1 week for most persistent data (Clients, etc.)
* 1 day for messages

(imported from commit d57bb2c6b9626ffa2155c6d0ef9b60827d1f2381)
2013-03-28 07:36:10 -04:00
Tim Abbott e2d010ef2d Fix most unnecessary database queries in huddle creation.
This saves 2 database queries per user in the huddle when sending the
first message to a particular huddle.

(imported from commit f71aa32df846fb4b82651a93ff9608087ffcaa5a)
2013-03-28 07:36:10 -04:00
Tim Abbott 3d39341fc2 Fix logging configuration for Django 1.5.
Apparently, something in Django 1.5's changes to their default logging
setup resulted in the logger 500 errors (logged in
django.core.handlers.base.handle_uncaught_exception) from reaching the
root logger -- they stopped at propagating at the 'django' logger.  We
deal with this by making our logging system handle those events in the
'django' logger ourselves (and making the related changes needed to
ensure that we still log to server.log and the console everything
logged by our own humbug.requests logger and anything that falls
through to the root logger).

This requires updating the mechanism we use in test_settings.py to
silence our request logging, since now the 'humbug.requests' logger is
being re-initialized by the Django logging setup, which runs after
test_settings.py.

While we're at it, set propagate=False in the commented-out
'django.db' logging configuration (previously, queries would be logged
twice).

(imported from commit 32af29084e52be1ba6f92a7952c3a3946925b46b)
2013-03-28 07:36:10 -04:00
Zev Benjamin 304899cd8a blueslip: Indicate whether users saw an error in the error emails
(imported from commit dd31976a3279df5ea5de2a0433387c82c8f80d41)
2013-03-27 21:53:58 -04:00
Zev Benjamin 4d30089220 blueslip: Only try to report a given error once every 5 minutes
This is in addition to only successfully reporting a given error once
per session.  Previously, if an error was triggered many times before
the ajax call to report the error returned, we'd end up making many
ajax requests to report the error.

(imported from commit 559179e3c8c3fbf03bbb091a67361d447c80b7bb)
2013-03-27 21:52:55 -04:00
Zev Benjamin d1b9ab9fd8 Move SERVER_GENERATION definition to settings.py
(imported from commit 4be2b912a63f49f525c66f46db0bc5c466ad364f)
2013-03-27 14:15:03 -04:00
Zev Benjamin 5b4536172c Allow @has_request_variables on functions that don't actually use it
(imported from commit 3cf6db06c16d3d107a0fc4b11fc8c0f0258fc306)
2013-03-27 14:15:03 -04:00
Zev Benjamin 203b0fcc25 Use json_to_bool instead of simplejson.loads
(imported from commit 0d045c606925379450215349a17d6fe04d3f1be9)
2013-03-27 14:15:03 -04:00
Zev Benjamin 2da4c0a4bf Remove extraneous SERVER_GENERATION definition
It looks like this was supposed to be moved in e0d9182c but was
copied, instead.

(imported from commit 094f43e9cfd4dde380a3d1ef79b1c273b54ce1a3)
2013-03-27 14:15:03 -04:00
Zev Benjamin 878646542f deploy-branch: Check out original ref by name if possible
(imported from commit eefc68574f1d1a94f1284670df18f59ef2aa1aa5)
2013-03-27 14:15:03 -04:00
Tim Abbott 4502e563d1 Reduce code duplication for coding filling memcached caches.
(imported from commit e7e053c6fa27fd7a1143696196e9ee974ec91c8f)
2013-03-27 12:59:24 -04:00
Tim Abbott 8fbc98601b Populate cache of Huddle objects on server restart.
(imported from commit 3214cfa70d0de01c42028a9d025f7607f609081b)
2013-03-27 12:59:24 -04:00
Tim Abbott 8b2cb6472b Cache the lookup of Huddle objects by hash.
This is used in the send_message code path.

(imported from commit 4d9a4d079fe5b10b94c11016e9ec8c5601addc2c)
2013-03-27 12:59:24 -04:00
Tim Abbott f5a19348e5 [puppet] Increase memcached memory limit to 256MB.
Because we're storing 25,000+ message content objects in memcached on
server restart, we were sometimes exceeding the 64MB cap even during
the restart process.  256MB should be safely large enough to not have
the issue but not so large as to seriously consume resources on our
app frontends (which currently have 7GB of RAM).

(imported from commit 1a64319e50c9dadf0bc65e2e4dbf08f4cc1b9c38)
2013-03-27 12:59:24 -04:00
Tim Abbott 6d41fa4118 [puppet] Add memcached.conf to puppet.
(imported from commit 67fcf112ca876e89f69fe58f905cf4bf3195797a)
2013-03-27 12:59:23 -04:00
Tim Abbott b2e76f50b9 Populate cache of Client objects on server restart.
(imported from commit 6d0ef309dadcd6c24fc9e17b0859becb053adccf)
2013-03-27 12:59:23 -04:00
Tim Abbott 36f09729e6 Run the memcached cache filling jobs in separate processes.
This will significantly improve the speed with which the memcached
caches are filled.

(imported from commit 445fec710a00b3d19b7962beddf89d4a75322eab)
2013-03-27 12:59:23 -04:00
Tim Abbott a774598a10 Populate cache of Recipient objects on server restart.
(imported from commit 752851c7c3ee565201dd59fb0455c82a8885d42d)
2013-03-27 12:59:23 -04:00
Tim Abbott cc065a3c90 Populate cache of Stream objects on server restart.
(imported from commit 131eeddc5ebe5cc0db2554514a730d2750078012)
2013-03-27 12:59:23 -04:00
Zev Benjamin 4fd1281f3c puppet: Log when Postgres uses temporary files
(imported from commit fee3df561c865d5238d4409f0607dba9b1fce4d3)
2013-03-27 11:36:00 -04:00
Zev Benjamin 6a6cfaf56a puppet: Add more postgresql.conf settings for streaming replication
(imported from commit 6cc6180053e038777b65c6bbdac1944d30bcc93b)
2013-03-27 11:36:00 -04:00
Zev Benjamin 2faaf50514 puppet: Add postgres replication user
(imported from commit 92c3a28584f6d83cc187314f5e7b17b4def18321)
2013-03-27 11:36:00 -04:00
Zev Benjamin 1658d31004 puppet: Go back to using IP addresses in pg_hba.conf
Postgres requires DNS reverse resolution in order to use hostnames.

(imported from commit 57304a6703c06e3860a87d021b7f99561ca4bac6)
2013-03-27 11:36:00 -04:00
Zev Benjamin 7bd21857c8 puppet: When using hostnames in pg_hba.conf, don't specify a CIDR mask
(imported from commit c60dd315886e13693de4603c3965db22a3caccfd)
2013-03-27 11:36:00 -04:00
Leo Franchi 79102044f4 Don't create a pika-connecting queue client if we have no RabbitMQ
(imported from commit 680e867abb61644cbc62a4280b4e47b03eb5abe7)
2013-03-27 11:06:10 -04:00
Tim Abbott 6fd4bf38c0 logs: Don't display database time when there were no queries.
(imported from commit 71297c920b63578ebc2770954345bfb9d4d8937f)
2013-03-27 08:19:27 -04:00
Tim Abbott 144987e581 logs: Provide total time passed for longpolled requests.
Also improve display of times passed -- we now use display short times
in milliseconds for easier reading.

(imported from commit 08e1e7e6acbef48453080864946f7602a3395e7c)
2013-03-27 08:19:27 -04:00
Tim Abbott 887389d16c logs: Output timestamps in milliseconds when less than a second.
(imported from commit 150038059a1d7c677004edf27d4af2e48bf41285)
2013-03-27 08:19:27 -04:00
Tim Abbott f3ad2d7a6b Centralize dispatch logic for which queue processor to use.
Previous we had around 4 copies of the logic for deciding whether we
should publish data via a SimpleQueueClient queue, a
TornadoQueueClient queue, or to directly handle the operation, which
resulted in their getting out of sync and buggy (see e.g. the previous
commit).

We need to add a lock around adding things to the queue to work around
a bug with pika's BlockingConnection.

I should note that the previous logic in some places had a bunch of
tests of the form "elif settings.TEST_SUITE" for doing the work that
would have been done by the queue processor directly; these should
have just been "else" clauses -- since we generally want that code to
run on development environments whether or not the test suite is
currently running.

(imported from commit 16bdbed4fff04b1bda6fde3b16bee7359917720b)
2013-03-27 08:19:27 -04:00
Tim Abbott 16574806f5 Don't initialize SimpleQueueClient inside Tornado.
Previously we had several files which initialized SimpleQueueClient()
for sending items to the UserActivity queue, even though those code
paths aren't used outside Tornado.  This resulted in slower Tornado
startup times.

(imported from commit ad97021ec18d3927233744037c548c22db33c321)
2013-03-27 08:19:27 -04:00
Tim Abbott 1df99937a9 Tornado: Fill the Tornado UserMessage cache using manual query.
The actual database query that we use to fill the UserMessage cache
only takes a few hundred milliseconds to run; however the process of
iterating through the results would take 3-5 seconds because the
Django ORM is not very efficient for small tables where we're only
interested in the integer values in a couple columns.

So we can save most of that Tornado startup time by just doing this
one query manually; I left the original query next to it in a comment
so it is easy to keep it all up to date as we change our product.

(imported from commit ac4675bcdda5d812ebfbe211450c85ee2787ee66)
2013-03-27 08:19:27 -04:00
Tim Abbott 2aae6190d2 [django 1.5] Set ALLOWED_HOSTS variable in settings.py.
This only does something if DEBUG=False, but it's now required that
you set this on Django 1.5 or the server will silently serve up 500s
for every request (not the best failure mode).

(imported from commit fa226c644770c468d73143c8a49d5d29d282df27)
2013-03-27 08:19:26 -04:00
Tim Abbott 4076704476 [django 1.5] models: Always return a string from __repr__() methods.
See http://bugs.python.org/issue5876 for an explanation for why this
is needed -- basically __repr__() needs to return a string, not a
unicode object in Python 2.

This causes problems on Django 1.5 because the more expressive
exception code in model.objects.get() will crash with a __repr__()
containing non-ascii unicode characters.

(imported from commit f44085e67d9d14629b821a29bbf65738f1794d6c)
2013-03-27 08:19:26 -04:00
Tim Abbott fde2243dbc [django 1.5] Update read flags handling to use new Django 1.5 syntax.
(imported from commit af1e2608b6d6d3677bf6266980d8dc77739aa4ba)
2013-03-27 08:19:26 -04:00
Tim Abbott 4a91b4a1ea [django 1.5] Use new-style url syntax in templates.
Checked using the following (relevant for rebasing):

git grep url templates/ | grep -v "'django" | grep -v "'zephyr"

This appears to not have a good backwards-compatability story (well,
there is one involving a %load from the future, but it seems to not
work).

(imported from commit d740831658aa23cadbbb82082ac6a3738d449a1d)
2013-03-27 08:19:26 -04:00
Leo Franchi ae42e77ad6 Fix copy in Jira integration page
(imported from commit 12bae68313ca7497686a59bfcad93802ec2991cb)
2013-03-26 18:37:54 -04:00
Leo Franchi dbb2157457 Make home view unread count only count messages newer than the pointer
(imported from commit 0f699ed23f59380b04606bd30600373956f89ae4)
2013-03-26 18:34:16 -04:00
Leo Franchi 6573a4ebb0 Bump API version to 0.1.5
(imported from commit 7c8c66369971e44405219eddac7e8bb3ddb44063)
2013-03-26 18:20:08 -04:00