Commit Graph

5555 Commits

Author SHA1 Message Date
Sakis
a5ae9a21cd Merge pull request #2097 from alphagov/remove-http-healthcheck
Remove http healthcheck for api instances
2018-09-21 10:47:40 +01:00
Rebecca Law
1b7e0a8ec4 Merge pull request #2102 from alphagov/reduce-updates-to-notification
Reduce updates to notification
2018-09-20 16:01:43 +01:00
Rebecca Law
bb97a9038f Merge branch 'master' into reduce-updates-to-notification 2018-09-20 14:48:40 +01:00
Rebecca Law
b00308d122 Removed an update statement to notifications.
It's a small change, but we should remove any db operations that are not necessary.
2018-09-20 14:47:24 +01:00
Leo Hemsted
7c48dd2c4e Merge pull request #2100 from alphagov/notification-postage
Notification postage
2018-09-20 13:25:34 +01:00
Leo Hemsted
8e19a0742f remove default postage from noti history
also add test for notification_history properly setting
2018-09-20 12:26:58 +01:00
Leo Hemsted
4dc3f829e3 give letter notifications the postage from their service 2018-09-19 17:23:17 +01:00
Leo Hemsted
9021b43eb6 use pytest.param to contain marks like xfail or skip 2018-09-19 16:33:00 +01:00
Leo Hemsted
918e4b390f add postage to notification + noti_history
if it's a letter notification, postage must equal "first" or "second",
else it must equal null
2018-09-19 16:32:58 +01:00
Rebecca Law
645da3f33d Merge pull request #2098 from alphagov/postage-constraints
Add constraints to services.postage
2018-09-19 11:08:02 +01:00
Rebecca Law
01ef8dd379 Merge pull request #2099 from alphagov/add-valid-message
Added an info log message when the precompiled pdf is successful.
2018-09-19 11:05:12 +01:00
Rebecca Law
a30ed976f4 Added an info log message when the precompiled pdf is successful. This is because we can't tell when the letters are passing. 2018-09-18 17:46:19 +01:00
Rebecca Law
5f73dfdbe9 Added constraints to services.postage: not nullable and can only containt "first" or "second" 2018-09-18 17:41:25 +01:00
Rebecca Law
29a666302e Merge pull request #2092 from alphagov/letter-class-default-for-services
Add letter_class to Service
2018-09-18 17:03:55 +01:00
Rebecca Law
7200ccb452 Remove print 2018-09-18 16:44:07 +01:00
Rebecca Law
1c0892888f Change the name of letter_class to postage, this will match the domain language used in the documentation.
Updated the tests to answer review comments.
2018-09-18 15:22:08 +01:00
Athanasios Voutsadakis
2e12c68d2e Remove http healthcheck for api instances
This was introduced in #1811 as a way to avoid sending traffic to newly
created apps where gunicorn had not started yet, such as the case during
a scaling event. These days we depend mostly on scheduled scaling and we
rarely need to scale above the scheduled values.

Yesterday we had an event where (during a traffic spike) the healthcheck
failed causing the instance to be killed and sending a 5XX response code
to all the connections that this instance was handling at the time.

However, this instance was not unhealthy and was serving traffic. The
problem stems from a combination of using async workers, having to limit
the number of database connections and a thread holding onto a db
connection for the entire duration of the request.

Specifically, we end up having requests queued up in gunicorn waiting
for other requests to finish and release the db connection. Some pages
such as the dashboard generate queries that can take >5s.

If a healthcheck request is sent during a traffic spike and the instance in
question was "unfortunate" enough to get handled a few of these long
running queries, the healthcheck request will be queued up behind these
slow requests and will fail to receive a response within 1s [docs].

Ideally we should be able to configure the healthcheck timeout to a
value of our choosing, since we can end up in this situation again in
the future.

docs: https://docs.cloudfoundry.org/devguide/deploy-apps/healthchecks.html#types
2018-09-18 10:34:00 +01:00
Rebecca Law
efb618e956 Fix merge conflicts for the db migration file.
Update test_services_dao to stop using fixtures. This is a massive change. The only real change in the file is to check for the letter_class.
2018-09-17 15:45:29 +01:00
Rebecca Law
79815b4f8a In order to support sending letters by first class we need a way to know how the service wants us to send the letter.
To start with this will be an attribute on the service, at the time the notification is created it will look at Service.letter_class to decide what class to use for the letter.

This PR adds Service.letter class as a nullable column.
Updated the create_service and update_service method to default the value to second.

Subsequent PRs will add the check constraint to ensure we only get first or second in the letter_class column and make that column nullable.
This can't be done all at once because it will cause an error if someone inserts or updates a service during the deploy.
2018-09-17 11:27:43 +01:00
Chris Hill-Scott
39b01f145f Merge pull request #2090 from alphagov/glamorgan-rother-wealden
Add two new letter logos
2018-09-14 15:22:52 +01:00
Chris Hill-Scott
244e91021d Add two new letter logos 2018-09-14 13:58:50 +01:00
Alexey Bezhan
6ff9f81934 Merge pull request #2089 from alphagov/notification-history-onupdate
Change NotificationHistory.updated_at on update
2018-09-13 14:43:58 +01:00
Alexey Bezhan
c9ca720959 Change NotificationHistory.updated_at on update
Sets the updated_at to current time when the NotificationHistory
is modified (which happens occasionally for example to set status
to returned letter).
2018-09-13 14:09:09 +01:00
Rebecca Law
5b25b682d4 Merge pull request #2088 from alphagov/remove-trigger-letter-pdfs-for-day
Remove trigger-letter-pdfs-for-day
2018-09-13 13:30:04 +01:00
Rebecca Law
9b6d784876 Merge pull request #2087 from alphagov/remove-scheduled-notification-from-schema
Don't join to scheduled_notifications
2018-09-13 11:59:12 +01:00
Rebecca Law
f1b04193ca In this PR we remove trigger-letter-pdfs-for-day scheduled task and just call collate_letter_pdfs_for_day instead.
There was a datetime bug in the query which resulted in files not being sent to the postal provider.
The trigger-letter-pdfs-for-day task is no longer needed, so rather than fix the query just call collate_letter_pdfs_for_day directly.
Less code is always better.

Deployment considerations: I realized this is strictly not backwards compatible if the scheduled job is in progress and a task is on the queue that no longer exists. This is ok since we will deploy this well before 17:50.
2018-09-12 17:16:34 +01:00
Katie Smith
ae1ee85d12 Merge pull request #2049 from alphagov/pyup-update-sqlalchemy-1.2.10-to-1.2.11
Update sqlalchemy to 1.2.11
2018-09-12 11:24:28 +01:00
Katie Smith
3926453b1e Merge pull request #2079 from alphagov/pyup-update-pytest-cov-2.5.1-to-2.6.0
Update pytest-cov to 2.6.0
2018-09-12 11:24:19 +01:00
Katie Smith
36f11ab0d0 Merge pull request #2085 from alphagov/pyup-update-pytest-3.7.4-to-3.8.0
Update pytest to 3.8.0
2018-09-12 11:24:10 +01:00
Rebecca Law
f84087cd63 For the NotificationWithTemplateSchema exclude the scheduled_notifications so we do not query that table.
The scheduled_notifications is not used as of yet.
2018-09-11 16:52:56 +01:00
Rebecca Law
39b90f0b78 Merge pull request #2083 from alphagov/fix-date-conversion
Fix date conversion bug
2018-09-10 14:44:12 +01:00
Alexey Bezhan
aacc00e3a7 Merge pull request #2075 from alphagov/process-returned-letters-list
Process returned letters list
2018-09-07 14:54:56 +01:00
Rebecca Law
555df6b62d Merge pull request #2086 from alphagov/user-name-for-csv-download
Add created_by_name to the Notification.serialize_for_csv.
2018-09-07 11:37:32 +01:00
Rebecca Law
8aacfb289d Add created_by_name to the Notification.serialize_for_csv.
The concern about performnace degrading has been thought through. We do not believe there will be an adverse effect since the high volume users do not send off messages.
2018-09-07 10:22:45 +01:00
Alexey Bezhan
3787e2954b Add a task to process returned letter lists
Adds an API endpoint `/letters/returned` that accepts a list of
notification references and creates a task to update their status.

Adds a new task that uses the list of references to update the status
of notifications to 'returned-letter'.

The update is currently done using a single query and logs the
number of changed records (including notification history records).
This could potentially be done within the `/letters/returned` endpoint,
but creating a job right away allows us to extend this more easily
in the future (e.g. logging missing notifications or adding callbacks).

The job is using the database tasks queue.
2018-09-06 16:39:17 +01:00
pyup-bot
f8229806b1 Update pytest from 3.7.4 to 3.8.0 2018-09-06 14:48:33 +01:00
Alexey Bezhan
18ab7f3337 Add updated history count to dao_update_notifications_by_reference
For returned letter updates most notifications won't exist in the
notifications table, so in order to find out whether the reference
matches any known letters we need to check the count of updated
history records.
2018-09-04 16:55:22 +01:00
Alexey Bezhan
0dcf04def9 Add notification status for returned letters
We need to update letter notifications with a new status when DVLA
gives us a list of references for returned letters.

This adds the new status to the models and the DB.

DVLA call this 'returned mail', so I'm using it as the status name
since it seems less ambiguous than 'returned'.
2018-09-04 16:55:22 +01:00
Rebecca Law
af83e89ed6 Fix problem with invalid seconds in the timestamp of the dvla response file.
We got a file that had 60 for the seconds in the timestamp, which is not valid (0-59). This ignores the seconds in the timestamp to get around that.
2018-09-04 16:09:56 +01:00
Chris Hill-Scott
db64423ca8 Merge pull request #2081 from alphagov/add-domain-constraint-2
Add domain constraint 2
2018-09-04 14:47:38 +01:00
Chris Hill-Scott
d52ee4606a Add error handler for duplicate domain 2018-09-04 14:40:24 +01:00
Chris Hill-Scott
dcacce1a2c Merge pull request #2078 from alphagov/email-preheader
Bump utils to start sending email preheaders
2018-09-04 14:15:22 +01:00
Chris Hill-Scott
5d5047fb13 Add unique constraint to email branding domains
Does two things:

1. Revert "Revert "Add unique constraint to email branding domain""

This reverts commit af9cb30ef3.

2. Don’t allow empty string in email branding domain

Columns with multiple `null`s can have a uniqueness constraint. Columns
with multiple empty string values are not considered unique.

This commit:
- removes any duplicate empty string values
- casts empty strings to null string any time these columns are updated

---

Squashed into this single commits because these two things are not
atomic as individual commits.
2018-09-04 11:10:46 +01:00
Chris Hill-Scott
55b7b3b157 Merge pull request #2080 from alphagov/revert-2077-add-domain-constraint
Revert "Add unique constraint to email branding domain"
2018-09-04 11:01:40 +01:00
Chris Hill-Scott
af9cb30ef3 Revert "Add unique constraint to email branding domain" 2018-09-04 10:55:49 +01:00
Chris Hill-Scott
036974ca05 Merge pull request #2071 from alphagov/pyup-update-pytest-3.7.3-to-3.7.4
Update pytest to 3.7.4
2018-09-04 10:37:22 +01:00
Chris Hill-Scott
f1aa02f40c Merge branch 'master' into pyup-update-pytest-3.7.3-to-3.7.4 2018-09-04 10:22:12 +01:00
Chris Hill-Scott
129d45fcfd Merge pull request #2070 from alphagov/pyup-update-moto-1.3.4-to-1.3.5
Update moto to 1.3.5
2018-09-04 10:21:48 +01:00
Chris Hill-Scott
95936533e9 Merge pull request #2077 from alphagov/add-domain-constraint
Add unique constraint to email branding domain
2018-09-04 10:20:55 +01:00
Chris Hill-Scott
348461f38e Merge pull request #2074 from alphagov/pyup-update-coveralls-1.4.0-to-1.5.0
Update coveralls to 1.5.0
2018-09-04 10:20:49 +01:00