Skip to content

Commit

Permalink
Merge pull request #49 from codecov/dana/minor-changes-manual-trigger
Browse files Browse the repository at this point in the history
increase retry delay, include uploads with uploaded state as in progress
  • Loading branch information
dana-yaish authored Aug 2, 2023
2 parents f591fab + 0862ba0 commit 8059a71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions tasks/manual_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
notify_task_name,
pulls_task_name,
)
from shared.reports.enums import UploadState

from app import celery_app
from database.models import Commit, Pull
Expand Down Expand Up @@ -92,7 +93,7 @@ async def process_async_within_lock(
)
still_processing = 0
for upload in uploads:
if not upload.state:
if not upload.state or upload.state_id == UploadState.UPLOADED.db_id:
still_processing += 1
if still_processing == 0:
self.trigger_notifications(repoid, commitid, commit_yaml)
Expand All @@ -108,7 +109,7 @@ async def process_async_within_lock(
log.info(
"Retrying ManualTriggerTask. Some uploads are still being processed."
)
retry_in = 30
retry_in = 60 * 3**self.request.retries
self.retry(max_retries=5, countdown=retry_in)
except MaxRetriesExceededError:
log.warning(
Expand Down
9 changes: 8 additions & 1 deletion tasks/tests/unit/test_manual_trigger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from celery.exceptions import Retry
from shared.reports.enums import UploadState

from database.tests.factories import CommitFactory, PullFactory
from database.tests.factories.core import UploadFactory
Expand Down Expand Up @@ -86,9 +87,15 @@ async def test_manual_upload_completion_trigger_uploads_still_processing(
celery_app,
)
commit = CommitFactory.create()
upload = UploadFactory.create(report__commit=commit, state="")
upload = UploadFactory.create(report__commit=commit, state="", state_id=None)
upload2 = UploadFactory.create(
report__commit=commit,
state="started",
state_id=UploadState.UPLOADED.db_id,
)
dbsession.add(commit)
dbsession.add(upload)
dbsession.add(upload2)
dbsession.flush()
with pytest.raises(Retry):
result = await ManualTriggerTask().run_async(
Expand Down

0 comments on commit 8059a71

Please sign in to comment.