Accessing a Tenant Locally

How to get a sanitised version of a customer’s tenant on your local stack.

Background

There may be times when a customer will report a bug that is very specific to how they utilise the system. In these cases it may be very difficult to reproduce this bug without having access to a system that behaves like theirs. Due to this we have created a jenkins command that lets you download a sanitised version of their tenant. This tenant does not contain any sensitive data and all the people data has been anonymised.

Accessing a sanitised tenant

Exporting tenant data

To get access to a sanitised version of a tenant you must go to the Pipeline DB Dump page on jenkins This page will present you with a form that accepts a schema of the tenant you want to dump.

Jenkins DB dump page

Put your desired tenant name into the schema field. If the tenant name contains multiple words, use underscore to separate them (for example, master_large_demo), and set the compression to -Fc and press build. It should start a jenkins pipeline that will create a sql dump of that tenant.

This process will take a few minutes. Once the pipeline is complete you will have to reload the page first before being able to download the .sql file, which will be produced as a build artifact.

Jenkins successful dump

Viewing tenant locally

Once you have downloaded this file you must copy it into your lapis directory and run the following docker command:

docker compose run -e PGPASSWORD=database_secret --rm lapis pg_restore -h postgres -U test_user -d lapis --no-owner SQL_FILE

where SQL_FILE is the path to the file you just downloaded.

This will add the exported tenant schema into your local database, but you still will not be able to access it via your browser yet. You must also expose it as a network alias in your docker-compose.override.yml in your lapis repository. You should already have an aliases in your override file but if not the structure will be as follows:

services:
  local:
    networks:
      gateway:
        aliases:
          - TENANT_NAME.local.internihr.ninja

where TENANT_NAME is the schema name of the tenant you just imported.

Now, you should be able to navigate to this tenant URL on your local computer to access a sanitised copy of the tenant’s data. It’s time to debug, have fun!

Cleanup

It is company policy to never keep client data on local machines longer than needed, even sanitised data. Once you have finished with the data you must clean it up as follows:

  1. Delete the sql file you have downloaded from your lapis directory.

  2. Remove the tenant alias from your docker-compose.override.yml file.

  3. Drop the schema from your database using the following command:

    docker compose run -e PGPASSWORD=database_secret --rm lapis psql -h postgres -U test_user -d lapis -c "DROP SCHEMA TENANT_NAME cascade;"
    

    where TENANT_NAME is the schema name of the tenant you just imported.