Skip to content

update logging in award program certificate task - #16822

Merged
tasawernawaz merged 1 commit into
masterfrom
tasawer/learner-3165/fix-error-logging-on-program-certificate-error
Dec 11, 2017
Merged

update logging in award program certificate task #16822
tasawernawaz merged 1 commit into
masterfrom
tasawer/learner-3165/fix-error-logging-on-program-certificate-error

Conversation

@tasawernawaz

@tasawernawaz tasawernawaz commented Dec 7, 2017

Copy link
Copy Markdown
Contributor

LEARNER-3165

@edx/learner-spartans Please review.

@tasawernawaz tasawernawaz changed the title update logging in award program certificate task WIP: update logging in award program certificate task Dec 7, 2017
@tasawernawaz
tasawernawaz force-pushed the tasawer/learner-3165/fix-error-logging-on-program-certificate-error branch from 6c8d6e7 to 87b9f61 Compare December 8, 2017 09:49
@tasawernawaz tasawernawaz changed the title WIP: update logging in award program certificate task update logging in award program certificate task Dec 8, 2017
# keep trying to award other certs, but retry the whole task to fix any missing entries
LOGGER.exception('Failed to award certificate for program %s to user %s', program_uuid, username)
retry = True
error_message = 'Failed to award certificate for program %s to user %s', program_uuid, username

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move this inside if block


with mock.patch(TASKS_MODULE + '.LOGGER.info') as mock_info, \
mock.patch(TASKS_MODULE + '.LOGGER.exception') as mock_exception:
mock.patch(TASKS_MODULE + '.LOGGER.warning') as mock_exception:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also add test that after maximum retries exception is logged

@tasawernawaz
tasawernawaz force-pushed the tasawer/learner-3165/fix-error-logging-on-program-certificate-error branch from 87b9f61 to f657e63 Compare December 11, 2017 12:01
@tasawernawaz

Copy link
Copy Markdown
Contributor Author

@ahsan-ul-haq Addressed your comments. Please review it again.

@ahsan-ul-haq ahsan-ul-haq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One small comment rest looks fine to me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lets call this warning_message and move it inside if block as it is the only place it is used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will change it, also this is used in else block as well.

@tasawernawaz
tasawernawaz force-pushed the tasawer/learner-3165/fix-error-logging-on-program-certificate-error branch from f657e63 to a6f4f17 Compare December 11, 2017 12:16

@waheedahmed waheedahmed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just one comment, otherwise LGTM

# keep trying to award other certs, but retry the whole task to fix any missing entries
LOGGER.exception('Failed to award certificate for program %s to user %s', program_uuid, username)
retry = True
warning_message = 'Failed to award certificate for program {uuid} to user {username}.'.format(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be best if you add retrying at the end as well Failed to award certificate for program {uuid} to user {username}, retrying. It will add more clarity about this warning.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we have a info message below at this line for retrying.

@tasawernawaz
tasawernawaz merged commit e7ff023 into master Dec 11, 2017
@tasawernawaz
tasawernawaz deleted the tasawer/learner-3165/fix-error-logging-on-program-certificate-error branch December 11, 2017 13:26
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production on Tuesday, December 12, 2017.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

warning_message = 'Failed to award certificate for program {uuid} to user {username}.'.format(
uuid=program_uuid, username=username)

if countdown < MAX_RETRIES:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tasawernawaz That's not how this works. The retry method handles this logic for you.

countdown is a time delay and MAX_RETRIES is a number of attempts. These cannot be compared.
http://docs.celeryproject.org/en/latest/reference/celery.app.task.html#celery.app.task.Task.retry

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bderusha if retry logic already handling this. I think I only need to log message as warning, once retries are exceeded, error will be logged from retry logic ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants