Skip to content

Updating ONSPD

Will Roper edited this page Mar 17, 2021 · 8 revisions

Every ~3 months we need to update ONSPD. Polling Bot will raise an issue to tell us about the new release.

Unfortunately we can't easily grab the zip straight from the ONS website any more (the big file downloads all generate a temporary expiring token to stop us from doing this). I've taken to grabbing the latest one and saving it in https://ons-cache.s3.amazonaws.com/ because we need to be able to grab it in the WhereDIV deploy scripts as well.

To do this first upload it: aws s3 cp ONSPD_FEB_2021_UK.zip s3://ons-cache/onspd/

Then make sure it's readable: aws s3api put-object-acl --bucket ons-cache --key onspd/ONSPD_FEB_2021_UK.zip --acl public-read

Then we can run manage.py import_onspd_remote https://ons-cache.s3.amazonaws.com/onspd/ONSPD_MAY_2018_UK.zip (for example) to import it. Downloading and unzipping that file requires more memory than a t2.micro has, so run it from a beefier instance.

This can be done without disrupting production traffic

The steps to do this are:

  • Run manage.py import_onspd_remote https://ons-cache.s3.amazonaws.com/onspd/ONSPD_MAY_2018_UK.zip locally to make sure it works.
  • In ee_deploy/aws.yml change the instance_type from "t3.small" to "m5d.large" (basically something with more ram).
  • In ee_deploy/aws.yml Increment lc_num by one.
  • Set correct aws credentials and run the deploy (ansible-playbook aws.yml -e replace_all=True)
  • ssh in to the new machine and run manage.py import_onspd_remote https://ons-cache.s3.amazonaws.com/onspd/ONSPD_MAY_2018_UK.zip.
  • Change instance_type back to "t3.small"
  • In ee_deploy/aws.yml Increment lc_num by one.
  • deploy
  • Commit changes (this should just be the lc_num increase) to ee-deploy repository.