Commit Graph

5968 Commits

Author SHA1 Message Date
Leo Hemsted
208af8a508 Merge pull request #2318 from alphagov/letter-branding
Letter branding
2019-01-29 10:59:55 +00:00
Leo Hemsted
1cd498dd39 make integrity check more restrictive
previously, it was too loose - checking `"name" in str(exc)` returns
false positives.

By changing from three if statements to a loop we can cut down on
unnecessary code (and ensure that the returned objects are consistent),
and by using the full check constraint name we can be sure that we're
only capturing exactly the right errors. Additionally, don't return
the original data in the error message - it's obvious what the name is
because it'll be populated in the form you just filled in.
2019-01-28 17:01:13 +00:00
Sakis
b42a134133 Merge pull request #2324 from alphagov/bump-disk-space
Bump available disk space for API, sender and receipts workers
2019-01-28 11:36:26 +00:00
Athanasios Voutsadakis
97c0f90804 Bump available disk space for API, sender and receipts workers
They are the busiest services and if we don't deploy often to rotate
them they tend to fill their disk space.
2019-01-28 11:28:11 +00:00
Pea (Malgorzata Tyczynska)
29c1a39016 Merge pull request #2316 from alphagov/pyup-update-psycopg2-binary-2.7.5-to-2.7.7
Update psycopg2-binary to 2.7.7
2019-01-25 18:44:20 +00:00
Pea Tyczynska
3f984ecbf6 Update requirements.txt with new version of psycopg2-binary
also auto-bumped sub-dependencies.
2019-01-25 18:36:10 +00:00
Pea (Malgorzata Tyczynska)
8995db0e99 Merge pull request #2297 from alphagov/pyup-update-sqlalchemy-1.2.14-to-1.2.16
Update sqlalchemy to 1.2.16
2019-01-25 18:08:51 +00:00
Pea Tyczynska
aacd8c7c24 Update requirements.txt version of SQLAlchemy and subdependencies 2019-01-25 18:03:07 +00:00
Pea (Malgorzata Tyczynska)
c4fb5c04de Merge pull request #2241 from alphagov/pyup-update-flask-migrate-2.3.0-to-2.3.1
Update flask-migrate to 2.3.1
2019-01-25 17:43:35 +00:00
Pea Tyczynska
eca0afe1ff Update requirements.txt with new version of Flask-Migrate and subdependencies 2019-01-25 17:17:58 +00:00
Pea (Malgorzata Tyczynska)
b3bb7ea9ba Merge branch 'master' into pyup-update-flask-migrate-2.3.0-to-2.3.1 2019-01-25 16:49:26 +00:00
Pea (Malgorzata Tyczynska)
d562ba3fa3 Merge pull request #2299 from alphagov/pyup-update-pytest-xdist-1.24.1-to-1.26.0
Update pytest-xdist to 1.26.0
2019-01-25 16:48:15 +00:00
Pea (Malgorzata Tyczynska)
7d35f5d6a6 Merge branch 'master' into pyup-update-pytest-xdist-1.24.1-to-1.26.0 2019-01-25 16:39:04 +00:00
Pea (Malgorzata Tyczynska)
d15853a287 Merge pull request #2279 from alphagov/pyup-update-pytest-cov-2.6.0-to-2.6.1
Update pytest-cov to 2.6.1
2019-01-25 16:34:12 +00:00
Rebecca Law
4dbb54b5e7 Added an endpoint to get letter-branding by id. 2019-01-25 16:05:55 +00:00
Rebecca Law
e030c2be88 Removing platform_default as a concept. No service actually wants to send letters with the default hm-government logo so we are going to remove it as a constraint.
However, until we can create a letter without a logo, we will still default to hm-government, because the dvla_organisation is set on the service.
This does simplify the code.
Also removed the inserts to letter_branding in the data migration file, because we can deploy this before the rest of the work is finished. But we will need to do it later.
2019-01-25 15:03:01 +00:00
Rebecca Law
7ee1d67df7 Added endpoints for letter-branding. 2019-01-24 17:39:48 +00:00
Rebecca Law
0b7fca4167 Merge branch 'master' into letter-branding 2019-01-24 16:39:30 +00:00
Rebecca Law
f8eb72a537 Adding rest endpoints for letter-branding 2019-01-24 16:38:52 +00:00
Rebecca Law
c2272f7d23 Fix mock in unit test. Not sure why it passed locally with previous mock. 2019-01-24 11:24:00 +00:00
Rebecca Law
a66b078065 Change the mock 2019-01-24 11:13:50 +00:00
Sakis
65c574a49c Merge pull request #2317 from alphagov/fix-run-multiworker
Exit if celery processes are not running
2019-01-23 17:10:53 +00:00
Athanasios Voutsadakis
3528aab25b Kill the other processes started by the script
We use exec to start awslogs_agent and then a tail to print logs to
stdout. CF docs[1] recommend to use exec to start processes which seems
to imply that as long as there are commands running the container will
remain up and running.

This commit ensures that if there are no celery tasks running we will
kill any other processes that we have started, so that the container will
no longer be considered healthy by cloudfoundry and will be replaced.

1: https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html#start-commands
2019-01-23 16:23:58 +00:00
Athanasios Voutsadakis
fa4cff5eb7 Bump sender memory to 3GB 2019-01-23 16:00:00 +00:00
Toby Lorne
afcdf1f9a1 Exit if celery processes are not running
In 4427827b2f and celery monitoring was
changed from using PID files to actually looking at processes.

If celery workers get OOM killed (for instance) the container init
script would not restart them, this is because `get_celery_pids` would
not contain any processes that contained the string celery. This would
cause the pipe to fail (-o pipefail). APP_PIDS would not get updated but
the script would continue to run. This caused the script to not restart
the celery processes.

We think the correct behaviour when celery processes are killed (i.e.
there are no more celery processes running in a container) is to kill
the container. The PaaS should then schedule new ones which may
remediate the cause of the celery processes being killed.

Upon detection of no celery processes running, some diagnostic
information from the environment is sent to the logs, e.g.:

```
CF_INSTANCE_ADDR=10.0.32.4:61012
CF_INSTANCE_INTERNAL_IP=10.255.184.9
CF_INSTANCE_GUID=81c57dbc-e706-411e-6a5f-2013
CF_INSTANCE_PORT=61012
CF_INSTANCE_IP=10.0.32.4
```

Then the script (which is the container entrypoint) exits 1.

Co-author: @servingupaces @tlwr
2019-01-23 14:28:53 +00:00
Rebecca Law
e4ea208d06 Use the letter_branding logo if it exists otherwise fall back to the dvla_organisation logo. 2019-01-23 12:51:09 +00:00
pyup-bot
ca48665778 Update psycopg2-binary from 2.7.5 to 2.7.7 2019-01-22 18:16:07 +00:00
Rebecca Law
f11aa55e0b Adding new data models for letter branding. 2019-01-22 17:27:00 +00:00
Leo Hemsted
bd4b125ac3 Merge pull request #2315 from alphagov/nightly-task-typo
remove unnecessary job_types arg from remove_csv_files celery tasks
2019-01-22 11:16:07 +00:00
Leo Hemsted
f5198bf71d remove unnecessary job_types arg from remove_csv_files celery tasks 2019-01-22 10:31:37 +00:00
Rebecca Law
52a1b534ee Add a new data model LETTER_BRANDING to store the letters. Add a new data model SERVICE_LETTER_BRANDING to map the service to the letter brand.
This will replace services.dvla_organisation_id and dvla_organisation.
2019-01-21 13:59:27 +00:00
Leo Hemsted
f316c1d02b Merge pull request #2312 from alphagov/cronitor
create cronitor decorator that alerts if tasks fail
2019-01-21 12:50:28 +00:00
Sakis
be1dd57a6a Merge pull request #2307 from alphagov/reliable-celery-multi-pids
Handle celery PIDs more reliably
2019-01-21 10:49:42 +00:00
Leo Hemsted
e1760adcd3 suppress cronitor request errors 2019-01-18 15:36:53 +00:00
Leo Hemsted
754c65a6a2 create cronitor decorator that alerts if tasks fail
make a decorator that pings cronitor before and after each task run.
Designed for use with nightly tasks, so we have visibility if they
fail. We have a bunch of cronitor monitors set up - 5 character keys
that go into a URL that we then make a GET to with a self-explanatory
url path (run/fail/complete).

the cronitor URLs are defined in the credentials repo as a dictionary
of celery task names to URL slugs. If the name passed in to the
decorator  isn't in that dict, it won't run.

to use it, all you need to do is call `@cronitor(my_task_name)`
instead of `@notify_celery.task`, and make sure that the task name and
the matching slug are included in the credentials repo (or locally,
json dumped and stored in the CRONITOR_KEYS environment variable)
2019-01-18 15:36:53 +00:00
Leo Hemsted
d783e2b236 move tests from test_scheduled_tasks to test_nightly_tasks 2019-01-18 15:36:53 +00:00
Leo Hemsted
d3d56a3224 separate nightly tasks and other scheduled tasks.
other tasks is anything that is run on a different frequency than
nightly
2019-01-18 15:36:53 +00:00
Rebecca Law
ef4b2c0564 Merge pull request #2309 from alphagov/5-letter-logos
Add 5 new letter logos
2019-01-18 10:48:08 +00:00
Rebecca Law
39c9b86c35 Merge pull request #2310 from alphagov/remove-used-query
Remove unused query
2019-01-18 10:47:45 +00:00
Pea (Malgorzata Tyczynska)
64191a93c2 Merge pull request #2308 from alphagov/precompiled_postage_response
Return notification postage in response for .post_precompiled_letter_notification
2019-01-18 10:19:46 +00:00
Rebecca Law
6ac1f39fd0 Remove dao_fetch_monthly_historical_stats_by_template, a query using NotificationHistory that is no longer used. 2019-01-17 17:20:21 +00:00
Chris Hill-Scott
b238512260 Add 5 new letter logos 2019-01-17 17:06:35 +00:00
Athanasios Voutsadakis
4427827b2f Handle celery PIDs more reliably
This addresses some problems that existed in the previous approach:

1. There was a race condition that could occur between the time we were
looking for the existence of the .pid files and actually reading them.

2. If for some reason the .pid file was left behind after a process had
died, the script would never know because we do:

    kill -s ${1} ${APP_PID} || true
2019-01-17 16:55:44 +00:00
Rebecca Law
8d36d72494 Merge pull request #2306 from alphagov/drop-stats_template_usage_by_month
Drop stats_template_usage_by_month table as it is no longer needed.
2019-01-17 15:39:35 +00:00
Alexey Bezhan
90dc69b6bc Merge pull request #2303 from alphagov/ft-status-template-statistics
Change template statistics endpoint to use fact_notification_status_dao
2019-01-17 15:04:20 +00:00
Pea Tyczynska
9ab97d3481 Return notification postage in response for .post_precompiled_letter_notification 2019-01-16 16:57:57 +00:00
Pea (Malgorzata Tyczynska)
276a9a3828 Merge pull request #2293 from alphagov/choose_postage_for_precompiled
Choose postage on POST request for precompiled letters
2019-01-16 14:13:26 +00:00
Rebecca Law
e148eca6ff Drop stats_template_usage_by_month table as it is no longer needed. 2019-01-15 16:55:56 +00:00
Rebecca Law
ac9186f95a Merge pull request #2305 from alphagov/fix-template-usage-query
Add missing filter for template usage query
2019-01-15 16:25:23 +00:00
Rebecca Law
3dca36ecfc Actually test the right thing :) 2019-01-15 16:16:19 +00:00