Data support tasks

Create a data support main server

  1. Notify RBC Group of the new domain name for the new PostgreSQL server

  2. Adjust reserved disk space to 1% for large disks:

    tune2fs -m 1 /dev/md2
    

Dependent services

Redash
  1. Add or update the Redash data source for the new PostgreSQL server

  2. Add the Redash data source, if new, to the unrestricted Redash group

Tinyproxy
  1. Update the allowed IP addresses in the pillar/tinyproxy.sls file

  2. Deploy the docs service, when ready

Replica, if applicable
  1. Update the allowed IP addresses and hostname in the pillar/kingfisher_replica.sls file

  2. Deploy the kingfisher-replica service, when ready

Docker

  1. Check that docker.uid in the pillar/kingfisher_main.sls file matches the entry in the /etc/passwd file.

Docker apps

  1. Run migrations for Docker apps as the deployer user:

    su - deployer
    
    cd /data/deploy/kingfisher-process/
    docker compose run --rm web python manage.py migrate
    
    cd /data/deploy/pelican-frontend/
    docker compose run --rm web python manage.py migrate
    
  2. Pull new images and start new containers for each Docker app.

Pelican backend

Attention

A cron job updates the exchange_rates table every 12 hours. Complete this step before the next run.

The initial migrations for Pelican backend are run by Salt.

  1. Connect to the old server, and dump the exchange_rates table:

    sudo -i -u postgres psql -c '\copy exchange_rates (valid_on, rates, created, modified) to stdout' pelican_backend > exchange_rates.csv
    
  2. Copy the database dump to your local machine. For example:

    rsync -avz root@ocp13.open-contracting.org:~/exchange_rates.csv .
    
  3. Copy the database dump to the new server. For example:

    rsync -avz exchange_rates.sql root@ocp23.open-contracting.org:~/
    
  4. Populate the exchange_rates table:

    psql -U pelican_backend -h localhost -c "\copy exchange_rates (valid_on, rates, created, modified) from 'exchange_rates.csv';" pelican_backend
    

Kingfisher Collect

  1. SSH into the new server as the incremental user:

    1. Generate an SSH key pair:

      ssh-keygen -t rsa -b 4096 -C "incremental"
      
    2. Get the public SSH key:

      cat ~/.ssh/id_rsa.pub
      
  2. Add the public SSH key to the ssh.incremental list in the pillar/kingfisher_main.sls file:

    ssh:
      incremental:
        - ssh-rsa AAAB3N...
    
  3. Change cron.present to cron.absent in the salt/kingfisher/collect/incremental.sls file.

  4. Deploy the old server and the new server.

  5. SSH into the old server as the incremental user:

    1. Stop any processes started by the cron jobs.

    2. Dump the kingfisher_collect database:

      pg_dump -U kingfisher_collect -h localhost -f kingfisher_collect.sql kingfisher_collect
      
  6. SSH into the new server as the incremental user.

    1. Copy the database dump from the old server. For example:

      rsync -avz incremental@ocp04.open-contracting.org:~/kingfisher_collect.sql .
      
    2. Load the database dump:

      psql -U kingfisher_collect -h localhost -f kingfisher_collect.sql kingfisher_collect
      
    3. Copy the data directory from the old server. For example:

      rsync -avz incremental@ocp04.open-contracting.org:/home/incremental/data/ /home/incremental/data/
      
    4. Copy the logs directory from the old server. For example:

      rsync -avz incremental@ocp04.open-contracting.org:/home/incremental/logs/ /home/incremental/logs/
      
  7. Remove the public SSH key from the ssh.incremental list in the pillar/kingfisher_main.sls file.

  8. Change cron.absent to cron.present in the salt/kingfisher/collect/incremental.sls file.

  9. Deploy the new server.

  10. Update spiders in Kingfisher Collect.

Create a data support replica server

  1. Update postgres.replica_ipv4 (and postgres.replica_ipv6, if applicable) in the pillar/kingfisher_main.sls file.