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

Add point_alias DAG and add alias params to create_new_es_index DAGs #3890

Merged
merged 11 commits into from Mar 14, 2024

Conversation

stacimc
Copy link
Contributor

@stacimc stacimc commented Mar 9, 2024

Fixes

Fixes #3493 by @stacimc

Description

This PR adds DAGs for pointing a target_alias at an existing elasticsearch index, with one DAG each for staging and production. Before the alias is applied, it will first be removed from the index to which it currently points (if applicable). There is also an option to delete this pre-existing index if desired. This was done by slightly extending the existing point_alias taskgroup from the create_proportional_by_source_staging_index DAG.

The point_alias task group is then used in a separate point_<environment>_alias DAG factory, and also added as a step to the create_new_<environment>_es_index DAGs to add functionality to those DAGs as well.

Testing Instructions

Test that create_proportional_by_source_staging_index DAGs still work

  1. Run the DAG locally with default params and verify it all passes. In elasticvue you should see a new index with a name like audio-50-percent-proportional-20240308t235423 and the alias audio-subset-by-source.
  2. Run the DAG a second time and verify all passes. This time audio-subset-by-source should have been removed from the index created in the previous step, and applied to a new index with a later timestamp.

Test the new DAG

  1. Run point_staging_alias locally. Pass in an existing index and an alias that does not currently exist. Verify that the alias gets added to the selected index. remove_alias_from_existing_index and delete_old_index steps will be skipped.
  2. Run again using the same alias, pointed to a different index. This time remove_alias_from_existing_index will not be skipped; the alias should be removed from the old index before being applied to the new one. delete_old_index is still skipped.
  3. Run again using the same alias and another index but also enable should_delete_old_index. This time no tasks should be skipped, and the alias should not only be moved to the new index but the old index should be deleted entirely.

Test create_new__es_index DAGs

  1. Run create_new_staging_es_index and do NOT pass in a target_alias. It should pass, and all the point_alias steps should be skipped.
  2. Run again, but this time pass in an alias that does not already exist. Verify that it is added to your new index, and remove_alias_from_existing_index and delete_old_index steps are skipped
  3. Run again with the same alias. Verify that it is added to your new index and removed from the index created in the previous step.
  4. Run again with the same alias, and should_delete_old_index enabled. Verify it is added to the new index, and the index created in step 3 is deleted.

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.

* `point_alias` needs to have trigger_rule=TriggerRule.NONE_FAILED, because the previous step to remove existing alias my be skipped
* however, this is a problem for DAGs that import the entire point_alias taskGroup and try to skip it using a branching operator. Because `point_alias` runs when NONE_FAILED, it will try to run even though the entire taskgroup has been skipped.
* easiest solution is to have all the individual tasks in the point_alias group individually handle skipping if the appropriate params haven't been passed in
@stacimc stacimc added 🟨 priority: medium Not blocking but should be addressed soon ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository 🧱 stack: catalog Related to the catalog and Airflow DAGs labels Mar 9, 2024
@stacimc stacimc self-assigned this Mar 9, 2024
Copy link

github-actions bot commented Mar 9, 2024

Full-stack documentation: https://docs.openverse.org/_preview/3890

Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again.

You can check the GitHub pages deployment action list to see the current status of the deployments.

Changed files 🔄:

@stacimc stacimc marked this pull request as ready for review March 9, 2024 00:34
@stacimc stacimc requested review from a team as code owners March 9, 2024 00:34
@stacimc stacimc requested review from fcoveram, sarayourfriend, krysal and AetherUnbound and removed request for fcoveram March 9, 2024 00:34
@stacimc stacimc mentioned this pull request Mar 11, 2024
16 tasks
Copy link
Contributor

@AetherUnbound AetherUnbound 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 awesome and very straightforward! Local testing worked and made sense, just a few questions for you on it.

catalog/dags/common/elasticsearch.py Outdated Show resolved Hide resolved
catalog/dags/common/elasticsearch.py Outdated Show resolved Hide resolved
catalog/dags/common/elasticsearch.py Outdated Show resolved Hide resolved
@krysal krysal marked this pull request as draft March 11, 2024 20:55
@krysal krysal removed the request for review from sarayourfriend March 11, 2024 21:00
@stacimc stacimc marked this pull request as ready for review March 12, 2024 17:01
Copy link
Contributor

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

Fantastic! All the local tests work for me just as expected. I'm glad we were able to combine those point steps into a single action 🚀

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.

Works as expected! LGTM ✅

@stacimc stacimc merged commit f73ed6c into main Mar 14, 2024
45 checks passed
@stacimc stacimc deleted the add/point-alias-dag branch March 14, 2024 18:51
@WordPress WordPress deleted a comment from Saschaym Mar 24, 2024
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: improvement Improvement to an existing user-facing feature 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: catalog Related to the catalog and Airflow DAGs
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Make a DAG for pointing ES aliases
3 participants