Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
a02dac29
Commit
a02dac29
authored
7 years ago
by
Tasawer Nawaz
Browse files
Options
Downloads
Patches
Plain Diff
Fix retries logic in award program certificate task
LEARNER-3165
parent
c1d02529
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openedx/core/djangoapps/programs/tasks/v1/tasks.py
+3
-8
3 additions, 8 deletions
openedx/core/djangoapps/programs/tasks/v1/tasks.py
openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
+0
-31
0 additions, 31 deletions
...edx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
with
3 additions
and
39 deletions
openedx/core/djangoapps/programs/tasks/v1/tasks.py
+
3
−
8
View file @
a02dac29
...
...
@@ -194,14 +194,9 @@ def award_program_certificates(self, username):
)
except
Exception
:
# pylint: disable=broad-except
# keep trying to award other certs, but retry the whole task to fix any missing entries
warning_message
=
'
Failed to award certificate for program {uuid} to user {username}.
'
.
format
(
uuid
=
program_uuid
,
username
=
username
)
if
countdown
<
MAX_RETRIES
:
LOGGER
.
warning
(
warning_message
)
retry
=
True
else
:
LOGGER
.
exception
(
"
Max retries exceeded. {msg}
"
.
format
(
msg
=
warning_message
))
LOGGER
.
warning
(
'
Failed to award certificate for program {uuid} to user {username}.
'
.
format
(
uuid
=
program_uuid
,
username
=
username
))
retry
=
True
if
retry
:
# N.B. This logic assumes that this task is idempotent
...
...
This diff is collapsed.
Click to expand it.
openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
+
0
−
31
View file @
a02dac29
...
...
@@ -275,37 +275,6 @@ class AwardProgramCertificatesTestCase(CatalogIntegrationMixin, CredentialsApiCo
mock_info
.
assert_any_call
(
mock
.
ANY
,
1
,
self
.
student
.
username
)
mock_info
.
assert_any_call
(
mock
.
ANY
,
2
,
self
.
student
.
username
)
@mock.patch
(
TASKS_MODULE
+
'
.MAX_RETRIES
'
,
0
)
def
test_retries_exceeded
(
self
,
mock_get_completed_programs
,
mock_get_certified_programs
,
mock_award_program_certificate
,
):
"""
Checks that a single failure to award one of several certificates
does not cause the entire task to fail. Also ensures that
successfully awarded certs are logged as INFO and exception is logged
for failed requests if retires are exceeded.
"""
mock_get_completed_programs
.
return_value
=
[
1
,
2
]
mock_get_certified_programs
.
side_effect
=
[[],
[
2
]]
mock_award_program_certificate
.
side_effect
=
self
.
_make_side_effect
([
Exception
(
'
boom
'
),
None
])
with
mock
.
patch
(
TASKS_MODULE
+
'
.LOGGER.info
'
)
as
mock_info
,
\
mock
.
patch
(
TASKS_MODULE
+
'
.LOGGER.exception
'
)
as
mock_exception
:
tasks
.
award_program_certificates
.
delay
(
self
.
student
.
username
).
get
(
retries
=
0
)
self
.
assertEqual
(
mock_award_program_certificate
.
call_count
,
2
)
mock_exception
.
assert_called_once_with
(
'
Max retries exceeded. Failed to award certificate for program {uuid} to user {username}.
'
.
format
(
uuid
=
1
,
username
=
self
.
student
.
username
)
)
mock_info
.
assert_any_call
(
mock
.
ANY
,
2
,
self
.
student
.
username
)
def
test_retry_on_programs_api_errors
(
self
,
mock_get_completed_programs
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment