Skip to content

Fix bug in notifications #5678

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

Merged
merged 3 commits into from
May 9, 2019
Merged
Changes from all 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
19 changes: 9 additions & 10 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def run(
return False

# Catch unhandled errors in the setup step
except Exception as e: # noqa
except Exception:
log.exception(
'An unhandled exception was raised during build setup',
extra={
Expand All @@ -411,14 +411,14 @@ def run(
self.setup_env.update_build(BUILD_STATE_FINISHED)

# Send notifications for unhandled errors
self.send_notifications()
self.send_notifications(version_pk, build_pk)
return False
else:
# No exceptions in the setup step, catch unhandled errors in the
# build steps
try:
self.run_build(docker=docker, record=record)
except Exception as e: # noqa
except Exception:
log.exception(
'An unhandled exception was raised during project build',
extra={
Expand All @@ -439,7 +439,7 @@ def run(
self.build_env.update_build(BUILD_STATE_FINISHED)

# Send notifications for unhandled errors
self.send_notifications()
self.send_notifications(version_pk, build_pk)
return False

return True
Expand Down Expand Up @@ -497,7 +497,7 @@ def run_setup(self, record=True):
# triggered before the previous one has finished (e.g. two webhooks,
# one after the other)
if not isinstance(self.setup_env.failure, VersionLockedError):
self.send_notifications()
self.send_notifications(self.version.pk, self.build['id'])

return False

Expand Down Expand Up @@ -566,15 +566,14 @@ def run_build(self, docker, record):
# TODO the build object should have an idea of these states,
# extend the model to include an idea of these outcomes
outcomes = self.build_docs()
build_id = self.build.get('id')
except vcs_support_utils.LockTimeout as e:
self.task.retry(exc=e, throw=False)
raise VersionLockedError
except SoftTimeLimitExceeded:
raise BuildTimeoutError

# Finalize build and update web servers
if build_id:
if self.build.get('id'):
Copy link
Contributor

Choose a reason for hiding this comment

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

I had a slightly different fix for this in #5549.

self.update_app_instances(
html=bool(outcomes['html']),
search=bool(outcomes['search']),
Expand All @@ -586,7 +585,7 @@ def run_build(self, docker, record):
log.warning('No build ID, not syncing files')

if self.build_env.failed:
self.send_notifications()
self.send_notifications(self.version.pk, self.build['id'])

build_complete.send(sender=Build, build=self.build_env.build)

Expand Down Expand Up @@ -920,9 +919,9 @@ def build_docs_class(self, builder_class):
builder.move()
return success

def send_notifications(self):
def send_notifications(self, version_pk, build_pk):
"""Send notifications on build failure."""
send_notifications.delay(self.version.pk, build_pk=self.build['id'])
send_notifications.delay(version_pk, build_pk=build_pk)

def is_type_sphinx(self):
"""Is documentation type Sphinx."""
Expand Down