Commit Graph

5778 Commits

Author SHA1 Message Date
Alexey Bezhan
32f0236ff2 Merge pull request #2242 from alphagov/enable-sa-preping
Enable pessimistic DB connection disconnect handling
2018-11-30 16:18:31 +00:00
Alexey Bezhan
614a2dae2c Enable pessimistic DB connection disconnect handling
By default, SQLAlchemy will start a transaction with an
existing connection without checking that the connection
is still valid.

Enabling "pre-ping" makes the ORM send a `SELECT 1` when
acquiring a connection, which should help avoid some errors
caused by connections breaking during a DB failover.

The added statement has a constant overhead for all transactions,
so we should only keep it enabled when we're planning to switch
or upgrade the database server.

https://docs.sqlalchemy.org/en/latest/core/pooling.html#disconnect-handling-pessimistic
2018-11-30 15:41:58 +00:00
Alexey Bezhan
15849b421b Merge pull request #2233 from alphagov/flexible_retention_jobs_deletion
Delete jobs in accordance with flexible retention policies
2018-11-28 14:47:23 +00:00
Alexey Bezhan
452924faaf Update jobs archived flag before setting the default value
Running an update before setting the column default value reduces
the time the table is locked (since most rows don't have a NULL
value anymore), but the migration takes slightly longer to run
overall.
2018-11-28 14:38:59 +00:00
Pea Tyczynska
f941b8b146 Use archived flag to see if job needs deleting from s3 bucket 2018-11-28 14:38:59 +00:00
Pea Tyczynska
fd06924f3a Build a command to archive old jobs 2018-11-28 14:38:59 +00:00
Pea Tyczynska
50811c3b8e Archive job after corresponding file deleted from s3 2018-11-28 14:38:59 +00:00
Pea Tyczynska
641cb6ec36 Add archived column to jobs table with default value of false 2018-11-28 14:38:59 +00:00
Pea Tyczynska
e5fd027192 Move nightly tasks before introduction of archived flag on jobs 2018-11-28 14:38:59 +00:00
Pea Tyczynska
be6f37069b Change job selection dao to take flexible retention into account
Also test deleting jobs with flexible data retention

Also update tests for default data retention following logic
change: dao_get_jobs_older_than_data_retention now counts
today at the start of the day, not at a time when function runs
and updated tests reflect that
2018-11-28 14:37:43 +00:00
Rebecca Law
744389f557 Merge pull request #2239 from alphagov/remove-unused-task
Remove unused task
2018-11-28 13:45:28 +00:00
Alexey Bezhan
e6c581b5b7 Merge pull request #2240 from alphagov/service-rate-limit-info-not-error
Lower service rate limit log level to INFO
2018-11-28 10:50:41 +00:00
Alexey Bezhan
462c8db4c3 Lower service rate limit log level to INFO
Services reaching rate limits are triggering our alerts and make it
hard to find actual exceptions in the logs.

As far as the API is concerned this is not an exceptional state,
so we shouldn't log it as such.
2018-11-27 15:50:51 +00:00
Alexey Bezhan
e7a2f4c151 Update utils to 30.7.1 to silence 'Header missing' warnings
Brings in changes from https://github.com/alphagov/notifications-utils/pull/553
2018-11-27 15:50:33 +00:00
Rebecca Law
bffa783e8f The ftp app once updated the status of a job, since we no longer call the task we can delete it. 2018-11-27 14:37:36 +00:00
Leo Hemsted
3033015754 Merge pull request #2238 from alphagov/letter-500
look in correct bucket for letters sent after 5:30pm
2018-11-27 13:42:43 +00:00
Leo Hemsted
ba9a774e74 look in correct bucket for letters sent after 5:30pm
use the same function that we use when uploading, to ensure
consistency (that fn is also well tested already)
2018-11-27 12:21:41 +00:00
Katie Smith
5ad549ba2f Merge pull request #2235 from alphagov/bump-utils-to-3.7.0
Bump notifications-utils to 3.7.0
2018-11-26 14:25:48 +00:00
Katie Smith
0c3e7946b1 Merge pull request #2221 from alphagov/pyup-update-pytest-xdist-1.24.0-to-1.24.1
Update pytest-xdist to 1.24.1
2018-11-26 14:25:23 +00:00
Katie Smith
ff06d120e8 Bump notifications-utils to 3.7.0
Bumped notifications-utils to 3.7.0. Version 3.7.0 includes the
`convert_utc_to_bst` and `convert_bst_to_utc` functions and the
`LETTER_PROCESSING_DEADLINE` constant, so these have been removed from
this repo and anywhere using these has now been updated to get these
from `notifications-utils`.

Also bumped pytest by a patch version to bring in a bug fix.
2018-11-26 12:53:39 +00:00
Leo Hemsted
6d8534a8fb Merge pull request #2232 from alphagov/rename-staging-csv-uploads-bucket
Rename staging CSV uploads bucket to match other environments
2018-11-21 14:43:00 +00:00
Alexey Bezhan
1b1b443c69 Rename staging CSV uploads bucket to match other environments 2018-11-21 14:07:04 +00:00
Rebecca Law
ac3882900c Merge pull request #2230 from alphagov/delete-run-letter-jobs
Delete run letter jobs
2018-11-20 12:04:28 +00:00
Rebecca Law
e54a1da3ed Merge pull request #2231 from alphagov/update-error-message
Update error message to be more descriptive
2018-11-20 12:04:17 +00:00
Rebecca Law
7f8a1f64bd Merge branch 'delete-run-letter-jobs' of github.com:alphagov/notifications-api into delete-run-letter-jobs 2018-11-20 11:12:02 +00:00
Rebecca Law
e4783dcfa9 Fix unit test 2018-11-20 11:07:32 +00:00
Rebecca Law
d0cbdce6c4 Update the error message when a service does not have permission to send a notification type. 2018-11-20 11:01:48 +00:00
Rebecca Law
ee0719341f Remove letter_job_ids schema 2018-11-16 13:04:49 +00:00
Rebecca Law
7a16ac35bd Remove letter-jobs api
When we first built letters you could only send them via a CSV upload, initially we needed a way to send those files to dvla per job.
We since stopped using this page. So let's delete it!
2018-11-15 17:24:37 +00:00
Chris Hill-Scott
07078e804e Merge pull request #2229 from alphagov/bournemouth-hants
Add letter logos for Bournemouth and Hants
2018-11-15 15:00:32 +00:00
Chris Hill-Scott
20fedb31a9 Add letter logos for Bournemouth and Hants 2018-11-15 14:44:38 +00:00
Rebecca Law
870b42919a Merge pull request #2227 from alphagov/fix-error-msg
Remove the extra "to" in the message.
2018-11-13 14:35:20 +00:00
Rebecca Law
0163a6d9b7 Update marshmallow and SqlAlchemy dependencies 2018-11-13 14:19:53 +00:00
Rebecca Law
63c0c68afa Remove the extra "to" in the message. 2018-11-12 16:28:16 +00:00
Alexey Bezhan
89516f95a9 Merge pull request #2225 from alphagov/rename_rename
Change name of update method for template folder
2018-11-12 15:51:47 +00:00
Rebecca Law
4e8efaeffc Merge pull request #2226 from alphagov/fix-error-msg
Update error message
2018-11-12 15:38:02 +00:00
Rebecca Law
83d720bb7b Change error message, the folder id is not useful infomation to the user. 2018-11-12 15:25:48 +00:00
Pea Tyczynska
103033a330 Change name of update method for template folder
It was initialy called "rename" which does not comply with
RESTful CRUD (create, update, read, delete) naming practice.
We remove the 'rename' operation in favour of template folder
resource update endpoint as it allows us to extend it with other
attributes.
2018-11-12 14:28:07 +00:00
Katie Smith
d4506f7825 Merge pull request #2210 from alphagov/update-tasks-for-sender-id-part-2
Get and use sender_id from S3 metadata
2018-11-12 11:38:43 +00:00
Katie Smith
d20e35d075 Get and use sender_id from S3 metadata
The `save_email` and `save_sms` jobs were updated previously to take an
optional `sender_id` and to use this if it was available. This commit
now gets the `sender_id` from the S3 metadata if it exists and passes it
through the the tasks which save the job notifications. This means SMS
and emails sent through jobs can use a specified `sender_id` instead of
the default.
2018-11-12 10:59:48 +00:00
Katie Smith
8b5d48b113 Merge pull request #2209 from alphagov/update-tasks-for-sender-id-part-1
Pass sender_id argument to tasks
2018-11-12 10:59:07 +00:00
Katie Smith
30fe41fd43 Pass sender_id argument to tasks
Started passing `sender_id` to the `save_email`, `save_sms` and
`process_job` tasks, with a default value of `None`.

If `sender_id` is provided, the `save_email` and `save_sms` tasks will
use it to determine the reply-to email address or the SMS sender for the
notifications in the job. The `process_job` task will start using the
value in another commit.
2018-11-12 10:49:39 +00:00
Katie Smith
4b23075488 Delete unused parameters from the save_email and save_sms jobs
These both had default arguments of `api_key_id` and `key_type` which
were never being passed in, so these have been removed.
2018-11-12 10:49:39 +00:00
pyup-bot
2a74a6fb72 Update pytest-xdist from 1.24.0 to 1.24.1 2018-11-10 14:07:42 +00:00
Rebecca Law
5eb4460b11 Merge pull request #2218 from alphagov/move-folders
Move folders and templates to other folders
2018-11-09 16:52:17 +00:00
Rebecca Law
68cea04210 Fixed error message 2018-11-09 16:40:58 +00:00
Rebecca Law
591a2c897a Fix comments 2018-11-09 16:20:06 +00:00
Rebecca Law
63b305441c Add a check that the folder is not moved into itself.
By the way, the database will not let this happen, but this is a nicer error and is explicit to read as an invalid move.
2018-11-09 16:08:33 +00:00
Rebecca Law
1f86796949 Renamed url to /template-folder/<id>/contents, it's a more restful name.
Updated unit tests
Removed redundant logger
2018-11-09 15:54:39 +00:00
Rebecca Law
5df9a307be Merge branch 'master' into move-folders 2018-11-09 15:26:23 +00:00