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

Deploy staging API after staging DB restore #2211

Merged
merged 6 commits into from
Jun 9, 2023

Conversation

AetherUnbound
Copy link
Collaborator

@AetherUnbound AetherUnbound commented May 27, 2023

Fixes

Another step towards completing #1989, builds off of #2207

Description

This PR adds a step to the staging database restore DAG which pulls the most recent API package version and dispatches the staging API deployment workflow with that version. While the deployment workflow itself needs a follow-up update to allow the openverse-bot to run deployments, this does correctly trigger the deployment workflow! Example: https://github.com/WordPress/openverse-infrastructure/actions/runs/5096003624

Screenshot_2023-05-26_17-32-01

I added a similar mechanism for setting up the GitHubAPI as we had for the RdsHook, it seemed easiest for the two functions we were using it in. I also changed the flow a little to only report completion after the truncate & deployment steps were complete, rather than alongside.

Testing Instructions

To test this, follow the instructions in #2099 and #2207. Make sure you have the GITHUB_API_KEY Airflow Variable defined as well with our team PAT. When the DAG gets to these steps, it should appropriately kick off the staging API deployment (although it will fail until we make the appropriate adjustments to it).

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@AetherUnbound AetherUnbound requested a review from a team as a code owner May 27, 2023 00:49
@AetherUnbound AetherUnbound requested review from krysal and stacimc and removed request for a team May 27, 2023 00:49
@AetherUnbound AetherUnbound added 🟨 priority: medium Not blocking but should be addressed soon 🌟 goal: addition Addition of new feature 💻 aspect: code Concerns the software code in the repository 🧱 stack: api Related to the Django API 🧱 stack: catalog Related to the catalog and Airflow DAGs labels May 27, 2023
@AetherUnbound AetherUnbound requested a review from a team May 31, 2023 17:32
@AetherUnbound AetherUnbound force-pushed the feature/staging-deployment branch from 27cae2b to 2c00b15 Compare June 1, 2023 00:30
Copy link
Collaborator

@stacimc stacimc left a comment

Choose a reason for hiding this comment

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

Looks great, tested and was able to kick off the staging deploy, which failed as expected: https://github.com/WordPress/openverse-infrastructure/actions/runs/5147523267

🎉

@AetherUnbound AetherUnbound linked an issue Jun 2, 2023 that may be closed by this pull request
@openverse-bot
Copy link
Collaborator

Based on the medium urgency of this PR, the following reviewers are being gently reminded to review this PR:

@krysal
This reminder is being automatically generated due to the urgency configuration.

Excluding weekend1 days, this PR was ready for review 5 day(s) ago. PRs labelled with medium urgency are expected to be reviewed within 4 weekday(s)2.

@AetherUnbound, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings.

Footnotes

  1. Specifically, Saturday and Sunday.

  2. For the purpose of these reminders we treat Monday - Friday as weekdays. Please note that the operation that generates these reminders runs at midnight UTC on Monday - Friday. This means that depending on your timezone, you may be pinged outside of the expected range.

@krysal
Copy link
Member

krysal commented Jun 5, 2023

So in order to test this, from #2099 I need to:

  • Set the following environment variables:
    • AWS_RDS_CONN_ID=aws_rds
    • AIRFLOW_CONN_AWS_RDS=aws://<access-key>:<access-secret>@?region_name=us-east-1

then from #2207, trying locally I need to:

  • set AIRFLOW_CONN_POSTGRES_OPENLEDGER_API_STAGING=postgres://deploy:deploy@db:5432/openledger

and from here:

  • set the GITHUB_API_KEY and the PAT
  • run just api/init and just c
  • Trigger the DAG
  • Check it kick off the staging API deployment

(easy-peasy? lol...) I'll try now!

Copy link
Member

@krysal krysal left a comment

Choose a reason for hiding this comment

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

It ended up being easier to test the task subset of the change by doing a combination of marking as succeded & learning tasks. It worked perfectly!

CleanShot 2023-06-05 at 18 12 56@2x

@AetherUnbound
Copy link
Collaborator Author

This is definitely one of the most cross-system DAGs we have... 😅 Thanks for taking the time to test everything @krysal!

Base automatically changed from feature/staging-update-table-drop to main June 9, 2023 08:55
@AetherUnbound AetherUnbound force-pushed the feature/staging-deployment branch from ee90144 to 9e3b33b Compare June 9, 2023 08:57
@AetherUnbound AetherUnbound merged commit 6a8b184 into main Jun 9, 2023
@AetherUnbound AetherUnbound deleted the feature/staging-deployment branch June 9, 2023 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🌟 goal: addition Addition of new feature 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: api Related to the Django API 🧱 stack: catalog Related to the catalog and Airflow DAGs
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Staging database recreation DAG
4 participants