Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MongoDB to work for Router #549

Merged
merged 2 commits into from
Dec 16, 2021
Merged

Update MongoDB to work for Router #549

merged 2 commits into from
Dec 16, 2021

Commits on Dec 15, 2021

  1. Define replica set config for MongoDB 2.6

    This commit adds a definition for the replica set config to use for MongoDB 2.6. Previously in this repo we initialised a replica set without specifying any config, which has the effect of creating a config using the container id of said container running MongoDB 2.6. The issue here is that this replica set config is persisted to the `govuk-docker_mongo-2.6` volume, meaning that when the current container is eventually removed and a new container created to run MongoDB 2.6 the replica set won't be properly provisioned as it references the wrong container id.
    
    To get around this problem in govuk-docker, this commit specifies the replica set config to use during initialisation and uses the name of the container to route to, rather than the container id; through this change, the replica set config can remain persisted in the associated volume whilst containers come and go, all whilst enabling these new instances to take part in the replica set. This isn't a problem with MongoDB 2.6 in production as we're not running it in containers.
    
    For clarity, the replica set is used by Router to poll for updates to Routes, using the `optime` property from `rs.status()` to determine if it holds an up-to-date copy of routes; for more context [see this commit](alphagov/router@678ef63) and [RFC](https://github.com/alphagov/govuk-rfcs/blob/main/rfc-135-updating-routes-in-router.md).
    Karl Baker committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    03ab571 View commit details
    Browse the repository at this point in the history
  2. Update replicate-mongodb.sh script for Router database

    This commit updates the `replicate-mongodb.sh` script to work for the `router` and `draft-router` databases. Specifically, Router uses MongoDB 2.6, but the replication script previously made no provision for this and so wouldn't have worked for these databases.
    
    When restoring a back-up of either `router` or `draft-router` using MongoDB 2.6, a `sleep 60` has been added to allow for the replica set to properly initialise, as described by MongoDB when you run `rs.initiate()`; whilst I can't find any documentation related to this on the MongoDB docs, there are references to it elsewhere (see [here](https://medium.com/@ManagedKube/deploy-a-mongodb-cluster-in-steps-9-using-docker-49205e231319) and [here](https://www.ceondo.com/notes/mongodb/)).
    Karl Baker committed Dec 15, 2021
    Configuration menu
    Copy the full SHA
    f943256 View commit details
    Browse the repository at this point in the history