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

Support#457: Add Flightpath #871

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Support#457: Add Flightpath #871

wants to merge 16 commits into from

Conversation

BrianXu20
Copy link
Contributor

@BrianXu20 BrianXu20 commented May 23, 2022

Ticket: https://torchbox.monday.com/boards/1343847472/pulses/1343866317

This adds Flightpath to allow copy production data to development and also adds some new processors.

Birdbath:

  • Update base.py
  • Update docker-compose.yml
  • Update fabfile.py

Flightpath:

  • Create management command

Heroku:

Production

  • BIRDBATH_REQUIRED=false
  • dyno metadata enabled

Development

  • dyno metadata enabled

Audit Site: (custom processors)

  • ScholarshipEnquiryFormSubmission
  • ScholarshipEnquiryFormSubmission
  • StudentAccountAnonymiser (includes StudentPage and related records + Collections and User Groups)

Docs:

  • Docs Updated

Tasks:

  • Code Review
  • Deploy to staging
  • Staging reset
  • Staging testing
  • Deploy to production

@BrianXu20 BrianXu20 marked this pull request as draft May 23, 2022 09:13
@codecov-commenter
Copy link

codecov-commenter commented May 23, 2022

Codecov Report

Attention: Patch coverage is 4.06504% with 118 lines in your changes are missing coverage. Please review.

Project coverage is 52.12%. Comparing base (086956b) to head (0570c34).

Files Patch % Lines
rca/users/birdbath.py 0.00% 56 Missing ⚠️
...ca/utils/management/commands/_base_copy_command.py 0.00% 45 Missing ⚠️
fabfile.py 0.00% 4 Missing ⚠️
rca/enquire_to_study/birdbath.py 0.00% 4 Missing ⚠️
rca/scholarships/birdbath.py 0.00% 4 Missing ⚠️
rca/utils/management/commands/copy_db_to_dev.py 0.00% 4 Missing ⚠️
rca/settings/production.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #871      +/-   ##
==========================================
- Coverage   52.86%   52.12%   -0.74%     
==========================================
  Files         163      168       +5     
  Lines        7856     7977     +121     
  Branches      175      175              
==========================================
+ Hits         4153     4158       +5     
- Misses       3577     3693     +116     
  Partials      126      126              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BrianXu20 BrianXu20 force-pushed the support/457-flightpath branch 2 times, most recently from 390df23 to 5035ec0 Compare May 23, 2022 10:54
@BrianXu20 BrianXu20 marked this pull request as ready for review May 23, 2022 10:59
@nickmoreton
Copy link
Contributor

Hey @BrianXu20 With my limited knowledge here the script looks OK.

I think Kevin H may be the person to contact about testing etc. he has helped me with circle CI on this project recently.

1 similar comment
@nickmoreton
Copy link
Contributor

Hey @BrianXu20 With my limited knowledge here the script looks OK.

I think Kevin H may be the person to contact about testing etc. he has helped me with circle CI on this project recently.

@BrianXu20
Copy link
Contributor Author

BrianXu20 commented May 25, 2022

I have tested this is working on my local machine, and it copied the prod data directly.


====>> Send POST request to FlightPath
  #!/bin/bash -eo pipefail
export JOB_STATUS=$(curl -f -X POST -m 900 -H "Authorization: Token $FLIGHTPATH_AUTH_KEY" -d "source_key=$DEPLOYMENT_KEY&destination_key=$DEPLOYMENT_KEY&copy_media=1&from_backup=1" "https://flightpath.torchbox.com/copy/$HEROKU_APP_NAME_PRODUCTION/$HEROKU_APP_NAME_STAGING/")
echo $JOB_STATUS
export JOB_ID=$(echo $JOB_STATUS | jq -r '.job_id')
echo $JOB_ID

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   561  100   406  100   155    167     64  0:00:02  0:00:02 --:--:--   167
{"time_started":"2022-05-25T05:35:03.936973Z","job_id":"ec2df4ec-ffb6-48fa-aa69-8da838690da7","status":"started","metadata":{"source_app":"rca-production","destination_app":"rca-development","copy_media":true,"create_snapshot":false,"from_backup":true,"source_key":"xxx","destination_key":"xxx"},"log_output":""}
ec2df4ec-ffb6-48fa-aa69-8da838690da7
Success!

@BrianXu20
Copy link
Contributor Author

I have tested this is working on my local machine,


====>> Send POST request to FlightPath
  #!/bin/bash -eo pipefail
export JOB_STATUS=$(curl -f -X POST -m 900 -H "Authorization: Token $FLIGHTPATH_AUTH_KEY" -d "source_key=$DEPLOYMENT_KEY&destination_key=$DEPLOYMENT_KEY&copy_media=1&from_backup=1" "https://flightpath.torchbox.com/copy/$HEROKU_APP_NAME_PRODUCTION/$HEROKU_APP_NAME_STAGING/")
echo $JOB_STATUS
export JOB_ID=$(echo $JOB_STATUS | jq -r '.job_id')
echo $JOB_ID

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   561  100   406  100   155    167     64  0:00:02  0:00:02 --:--:--   167
{"time_started":"2022-05-25T05:35:03.936973Z","job_id":"ec2df4ec-ffb6-48fa-aa69-8da838690da7","status":"started","metadata":{"source_app":"rca-production","destination_app":"rca-development","copy_media":true,"create_snapshot":false,"from_backup":true,"source_key":"xxx","destination_key":"xxx"},"log_output":""}
ec2df4ec-ffb6-48fa-aa69-8da838690da7
Success!

.circleci/config.yml Outdated Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
@BrianXu20 BrianXu20 force-pushed the support/457-flightpath branch 2 times, most recently from 0af3ef2 to 2f32d87 Compare May 27, 2022 08:41
@nickmoreton
Copy link
Contributor

The latest changes you made look good.

@nickmoreton nickmoreton force-pushed the support/457-flightpath branch 2 times, most recently from 4af4415 to 7c18275 Compare September 14, 2022 16:57
.circleci/config.yml Outdated Show resolved Hide resolved
@victoriachan
Copy link
Contributor

Looks good except for the bit about HerokuAnonymisationAllowedCheck. I suggest removing that. Also the bit about fake email address being too realistic.

Suggestion: Birdbath is using version 0.0.5, I would suggest upgrading it to django-birdbath = "^1.0.0".

Copy link
Contributor

@victoriachan victoriachan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except for the bit about HerokuAnonymisationAllowedCheck. I suggest removing that. Also the bit about fake email address being too realistic.

Suggestion: Birdbath is using version 0.0.5, I would suggest upgrading it to django-birdbath = "^1.0.0".

rca/settings/base.py Outdated Show resolved Hide resolved
rca/enquire_to_study/birdbath.py Outdated Show resolved Hide resolved
rca/scholarships/birdbath.py Outdated Show resolved Hide resolved
@nickmoreton nickmoreton force-pushed the support/457-flightpath branch 8 times, most recently from d14b85f to 6b49711 Compare September 21, 2022 16:11
.circleci/config.yml Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
@nickmoreton
Copy link
Contributor

Hi @kevinhowbrook Could you please have a look at the last commits I made here.

It basically reverts earlier Student account anonymisation and brings it in line with our latest plan.

If it's OK I could push it to dev. Thanks

Copy link

@rachelhsmith rachelhsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tricky one!

I'm not sure if it is necessarily a problem but I noticed that running birdbath more than once on dev data throws an error. I got Exception: [IntegrityError('duplicate key value violates unique constraint "auth_group_name_key"\nDETAIL: Key (name)=(Student: joshua.good-0) already exists.\n')]

README.md Outdated Show resolved Hide resolved
docker-compose.yml Outdated Show resolved Hide resolved
rca/settings/base.py Show resolved Hide resolved
rca/users/birdbath.py Show resolved Hide resolved
@nickmoreton nickmoreton added the on-dev Flag to state if this code is on the dev site label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on-dev Flag to state if this code is on the dev site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants