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

Raise an exception if any indexer workers fail their health check #3726

Merged
merged 5 commits into from Feb 8, 2024

Conversation

AetherUnbound
Copy link
Contributor

Fixes

Fixes #2708 by @AetherUnbound

Description

This PR adds some exception handling to the case where the indexer workers fail their healthchecks. Those exceptions are now raised appropriately in the ingestion server and will be alerted to Slack along with other exceptions.

Testing Instructions

I added some unit tests for these cases - this is my first time using pook and I'm basing it off of other tests in the ingestion server suite, so let me know if I'm doing something that isn't idiomatic!

CI passing should be a positive indicator.

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 January 31, 2024 01:32
@github-actions github-actions bot added the 🧱 stack: ingestion server Related to the ingestion/data refresh server label Jan 31, 2024
@openverse-bot openverse-bot added 🟨 priority: medium Not blocking but should be addressed soon 🛠 goal: fix Bug fix 💻 aspect: code Concerns the software code in the repository labels Jan 31, 2024
@AetherUnbound AetherUnbound self-assigned this Feb 1, 2024
Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

This LGTM. I've shared some feedback on the pook usage to give hints for how to make the tests a bit simpler and leverage pook's abilities better (namely, by adding the expected body to the matcher, rather than manually checking it after the fact), but none of them are blockers, especially as the reviews on this PR have been delayed anyway.

for worker, mock_post, (start_id, end_id) in zip(
workers, post_mocks, expected_ranges
):
assert mock_post.calls > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion to use mock_post.matched (which itself does .calls > 0), or probably better, mock_post.done to ensure it was matched the expected number of times (in this case, once). matched and calls > 0 just checks if it was matched at all, not that it was matched the expected number of times. In this case it is 1, so there's no real difference, but semantically, and when considering the approach to take for other tests that may have multi-use mocks, .done is probably a more consistent and reliable assertion.

Comment on lines 63 to 69
assert data == {
"model_name": "sample_model",
"table_name": "sample_table",
"target_index": "sample_index",
"start_id": start_id,
"end_id": end_id,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than pulling the request data out of the pook mock, it's better to tell pook that's what to match in the first place:

pook.post(...).json({
  "model_name": "sample_model",
  "table_name": "sample_table",
  "target_index": "sample_index",
  "start_id": start_id,
  "end_id": end_id,
})

If pook sees a request that doesn't match the expected body, it will raise a no match exception, with a detailed diff showing why the actual request didn't match the expected request.

This also lets you avoid needing to think about pook's internals when pulling out the matched request data manually like this, and would remove the need for this complex secondary loop, which could be changed to just [assert mock.done for mock in post_mocks] or, better yet, pook.done, which checks that all mocks registered in context are exhausted.

Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com>
@AetherUnbound
Copy link
Contributor Author

Thanks so much for the idiomatic pook tips! I've applied those, hopefully they look okay :)

@openverse-bot
Copy link
Collaborator

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

@obulat
@stacimc
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.

Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

LGMT!

"start_id": start_id,
"end_id": end_id,
}
# Pook will raise an exception here if any requests don't match the above
Copy link
Contributor

Choose a reason for hiding this comment

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

Does pook raise the exception? I think it just returns the boolean 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, you're right - I'll reword this!

Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

CI passes and the code looks good.

if failures:
raise ValueError(
f"Some workers didn't respond to health check: {','.join(failures)}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm just curious, do you know what value will failures have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the worker URLs that were unable to be reached, see line 58 above!

@AetherUnbound AetherUnbound merged commit f8e6d35 into main Feb 8, 2024
41 checks passed
@AetherUnbound AetherUnbound deleted the fix/ingestion-server-raise-exception branch February 8, 2024 18:38
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: fix Bug fix 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: ingestion server Related to the ingestion/data refresh server
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Ingestion server does not appropriately report when indexer workers cannot be reached
4 participants