Skip to content
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

Fix part of #11202: Enable logging and add retry for create task #11209

Merged
merged 6 commits into from
Nov 22, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions core/platform/taskqueue/cloud_taskqueue_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
import logging

import feconf

from google.api_core import retry
from google.cloud import tasks_v2
from google.protobuf import timestamp_pb2

CLIENT = tasks_v2.CloudTasksClient()
# This is needed so that we can see whether the create_task is retried.
retry._LOGGER.setLevel(logging.DEBUG) # pylint: disable=protected-access


def create_http_task(
Expand Down Expand Up @@ -91,9 +95,8 @@ def create_http_task(
task['name'] = task_name

# Use the CLIENT to build and send the task.
# Note: retry=None means that the default retry arguments in queue.yaml are
# used.
response = CLIENT.create_task(parent, task, retry=None)
# Note: retry=retry.Retry() means that the default retry arguments are used.
Copy link
Member

Choose a reason for hiding this comment

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

Wait a sec -- one question about this. Does this mean that we no longer obey the stuff in queue.yaml? If so, that could be confusing if devs update queue.yaml and there is no effect there. Should we perhaps be setting this info in queue.yaml instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not entirnely sure whether the retry params in queue.yaml really work, since it seems that we have a lot of errors comming from this place, I want to try setting the retry here to see if that helps to reduce the number of errors that we get.

response = CLIENT.create_task(parent, task, retry=retry.Retry())

logging.info('Created task %s' % response.name)
return response
7 changes: 4 additions & 3 deletions core/platform/taskqueue/cloud_taskqueue_services_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import feconf
import python_utils

from google.api_core import retry as retry_lib
from google.protobuf import timestamp_pb2


Expand All @@ -53,7 +54,7 @@ def test_http_task_scheduled_immediately_sends_correct_request(self):
task_name = 'task1'

def mock_create_task(parent, task, retry=None):
self.assertIsNone(retry)
self.assertIsInstance(retry, retry_lib.Retry)
self.assertEqual(
parent,
u'projects/dev-project-id/locations/us-central1/queues/queue')
Expand Down Expand Up @@ -92,8 +93,8 @@ def test_http_task_scheduled_for_later_sends_correct_request(self):
timestamp = timestamp_pb2.Timestamp()
timestamp.FromDatetime(datetime_to_execute_task)
task_name = 'task1'
def mock_create_task(parent, task, retry=None):
self.assertIsNone(retry)
def mock_create_task(parent, task, retry):
self.assertIsInstance(retry, retry_lib.Retry)
self.assertEqual(
parent,
u'projects/dev-project-id/locations/us-central1/queues/queue')
Expand Down