-
Notifications
You must be signed in to change notification settings - Fork 12
feat: add upload breadcrumbs to test results tasks #716
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| from services.lock_manager import LockManager, LockRetry, LockType | ||
| from services.test_analytics.ta_finish_upload import ta_finish_upload | ||
| from shared.celery_config import test_results_finisher_task_name | ||
| from shared.django_apps.upload_breadcrumbs.models import Errors, Milestones | ||
| from shared.yaml import UserYaml | ||
| from tasks.base import BaseCodecovTask | ||
| from tasks.notify import notify_task_name | ||
|
|
@@ -35,6 +36,17 @@ def run_impl( | |
| } | ||
| log.info("Starting test results finisher task", extra=self.extra_dict) | ||
|
|
||
| bc_kwargs = { | ||
| "commit_sha": commitid, | ||
| "repo_id": repoid, | ||
| "task_name": self.name, | ||
| "parent_task_id": self.request.parent_id, | ||
| } | ||
|
|
||
| self._call_upload_breadcrumb_task( | ||
| milestone=Milestones.NOTIFICATIONS_TRIGGERED, **bc_kwargs | ||
| ) | ||
|
|
||
| lock_manager = LockManager( | ||
| repoid=repoid, | ||
| commitid=commitid, | ||
|
|
@@ -43,6 +55,10 @@ def run_impl( | |
| blocking_timeout=None, | ||
| ) | ||
|
|
||
| self._call_upload_breadcrumb_task( | ||
| milestone=Milestones.LOCK_ACQUIRING, **bc_kwargs | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nonexistent milestone enum values cause AttributeErrorHigh Severity
Additional Locations (2) |
||
|
|
||
| try: | ||
| # this needs to be the coverage notification lock | ||
| # since both tests post/edit the same comment | ||
|
|
@@ -51,13 +67,20 @@ def run_impl( | |
| max_retries=5, | ||
| retry_num=self.attempts, | ||
| ): | ||
| self._call_upload_breadcrumb_task( | ||
| milestone=Milestones.LOCK_ACQUIRED, **bc_kwargs | ||
| ) | ||
| finisher_result = self.process_impl_within_lock( | ||
| db_session=db_session, | ||
| repoid=repoid, | ||
| commitid=commitid, | ||
| commit_yaml=UserYaml.from_dict(commit_yaml), | ||
| **kwargs, | ||
| ) | ||
| self._call_upload_breadcrumb_task( | ||
| milestone=Milestones.LOCK_RELEASED, **bc_kwargs | ||
| ) | ||
|
|
||
| if finisher_result["queue_notify"]: | ||
| self.app.tasks[notify_task_name].apply_async( | ||
| args=None, | ||
|
|
@@ -68,9 +91,16 @@ def run_impl( | |
| }, | ||
| ) | ||
|
|
||
| self._call_upload_breadcrumb_task( | ||
| milestone=Milestones.NOTIFICATIONS_SENT, **bc_kwargs | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTIFICATIONS_SENT breadcrumb recorded when no notification sentMedium Severity The
Comment on lines
+94
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The Suggested FixMove the call to Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
||
| return finisher_result | ||
|
|
||
| except LockRetry as retry: | ||
| self._call_upload_breadcrumb_task( | ||
| error=Errors.INTERNAL_LOCK_ERROR, **bc_kwargs | ||
| ) | ||
| if retry.max_retries_exceeded: | ||
| log.error( | ||
| "Not retrying lock acquisition - max retries exceeded", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| from services.processing.types import UploadArguments | ||
| from services.test_analytics.ta_processor import ta_processor | ||
| from shared.celery_config import test_results_processor_task_name | ||
| from shared.django_apps.upload_breadcrumbs.models import Errors, Milestones | ||
| from tasks.base import BaseCodecovTask | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
@@ -25,14 +26,41 @@ def run_impl( | |
| arguments_list: list[UploadArguments], | ||
| **kwargs, | ||
| ) -> bool: | ||
| for argument in arguments_list: | ||
| ta_processor( | ||
| repoid=repoid, | ||
| commitid=commitid, | ||
| commit_yaml=commit_yaml, | ||
| argument=argument, | ||
| update_state=True, | ||
| upload_ids = [arg["upload_id"] for arg in arguments_list if "upload_id" in arg] | ||
|
|
||
| bc_kwargs = { | ||
| "commit_sha": commitid, | ||
| "repo_id": repoid, | ||
| "upload_ids": upload_ids, | ||
|
Comment on lines
+33
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The call to Suggested FixRemove the Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| "task_name": self.name, | ||
| "parent_task_id": self.request.parent_id, | ||
| } | ||
|
|
||
| self._call_upload_breadcrumb_task( | ||
| milestone=Milestones.PROCESSING_UPLOAD, **bc_kwargs | ||
| ) | ||
|
|
||
| try: | ||
| for argument in arguments_list: | ||
| ta_processor( | ||
| repoid=repoid, | ||
| commitid=commitid, | ||
| commit_yaml=commit_yaml, | ||
| argument=argument, | ||
| update_state=True, | ||
| ) | ||
| except Exception: | ||
| self._call_upload_breadcrumb_task( | ||
| error=Errors.UNKNOWN, | ||
| error_text="Unhandled exception during test results processing", | ||
| **bc_kwargs, | ||
| ) | ||
| raise | ||
|
|
||
| self._call_upload_breadcrumb_task( | ||
| milestone=Milestones.UPLOAD_COMPLETE, **bc_kwargs | ||
| ) | ||
|
|
||
| return True | ||
|
|
||
|
|
||
|
|
||


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.
Extra kwargs crash breadcrumb calls and break tasks
High Severity
The
bc_kwargsdicts includetask_nameandparent_task_id, but_call_upload_breadcrumb_taskonly acceptscommit_sha,repo_id,milestone,upload_ids,error, anderror_text— it does not accept**kwargs. When**bc_kwargsis unpacked at each call site, Python raises aTypeErrorfor the unexpected keyword arguments. This error occurs at the call site, not inside the method body, so the method's internaltry/exceptcannot catch it. Since the breadcrumb calls are meant to be fire-and-forget, this will instead crash the entire task.Additional Locations (1)
apps/worker/tasks/test_results_processor.py#L30-L37