-
Notifications
You must be signed in to change notification settings - Fork 373
Bug 1387418: Handle empty push resultset from hg #9074
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
Conversation
This patch parses the hg push resultset and handles cases where pushes are not present by raising an appropriate error and logging the error correctly.
Archaeopteryx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the patch. Please ask if there are questions about the review comments.
treeherder/etl/push_loader.py
Outdated
| try: | ||
| data = fetch_json(url) | ||
| except Exception as e: | ||
| logger.exception("Failed fetching push JSON from %s for %s: %s", url, repository, e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an f-string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in latest commit
treeherder/etl/push_loader.py
Outdated
| pushes = data.get("pushes") | ||
|
|
||
| if not pushes or not isinstance(pushes, dict): | ||
| # Log deg info and raise error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does deg mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a typo. I have corrected this in the latest commit.
treeherder/etl/push_loader.py
Outdated
| {"url": url, "repository": repository, "data_keys": data_keys}, | ||
| ) | ||
| except Exception: | ||
| logger.debug("NewRelic event failed for malformed data") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reword: NewRelic event failed for malformed Hg push data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I have made the updates.
treeherder/etl/push_loader.py
Outdated
| try: | ||
| push = next(iter(pushes.values())) | ||
| except Exception as e: | ||
| logger.exception("Failed to extract first push from pushes for {respository} {url}:{e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f-string declaration missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.
treeherder/etl/push_loader.py
Outdated
| pass | ||
|
|
||
|
|
||
| class ResultsetFetchError(Exception): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use HgPushFetchError instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes implemented.
treeherder/etl/push_loader.py
Outdated
| logger.exception("Failed fetching push JSON from %s for %s: %s", url, repository, e) | ||
| try: | ||
| newrelic.agent.record_custom_event( | ||
| "resultset_fetch_failure", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use hg_push_fetch_failure instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes Implemented
treeherder/etl/push_loader.py
Outdated
| except Exception: | ||
| # NewRelic failures should not block ingestion | ||
| logger.debug("NewRelic event failed for fetch error") | ||
| raise ResultsetFetchError(f"Failed to fecth JSON from {url}: {e}") from e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This has been corrected.
treeherder/etl/push_loader.py
Outdated
| ) | ||
| try: | ||
| newrelic.agent.record_custom_event( | ||
| "resultset_fetch_malformed", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use hg_push_fetch_malformed instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Made the below changes to push_loader.py * Used an f-string in line 267 to log exception * Corrected comment where we log data in warning * Used `NewRelic event failed for malformed Hg push data` in place of `NewRelic event failed for malformed data` * Inserted f-string declaration and corrected typo in it too * Renamed `ResultsetFetchError` to `HgPushFetchError` * Renamed `resultset_fetch_failure` to `hg_push_fetch_failure` * Corrected typo from `fecht` to `fetch` Made the below change to test_push_loader.py * Replace `ResultsetFetchError` with `HgPushFetchError`
|
Thank you for reviewing it and providing your feedback. Changes to
Change to
|
Archaeopteryx
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
* Bug 1387418: Handle empty push resultset from hg This patch parses the hg push resultset and handles cases where pushes are not present by raising an appropriate error and logging the error correctly. * Bug 1387418: Address review comments Made the below changes to push_loader.py * Used an f-string in line 267 to log exception * Corrected comment where we log data in warning * Used `NewRelic event failed for malformed Hg push data` in place of `NewRelic event failed for malformed data` * Inserted f-string declaration and corrected typo in it too * Renamed `ResultsetFetchError` to `HgPushFetchError` * Renamed `resultset_fetch_failure` to `hg_push_fetch_failure` * Corrected typo from `fecht` to `fetch` Made the below change to test_push_loader.py * Replace `ResultsetFetchError` with `HgPushFetchError`
Changes Introduced
This patch parses the hg push resultset and handles cases where pushes are not present by raising an appropriate error and logging the error correctly.
Testing Information
tests/etl/test_push_loader.pyto validate that the appropriate exception is raised whenfetch_jsonreturns adictwithoutpushes