Skip to content

Logging exceptions rework #5118

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 7 commits into from
Feb 19, 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
24 changes: 18 additions & 6 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
BuildEnvironmentError,
BuildEnvironmentWarning,
BuildTimeoutError,
MkDocsYAMLParseError,
ProjectBuildsSkippedError,
VersionLockedError,
YAMLParseError,
Expand All @@ -64,7 +65,7 @@
from readthedocs.worker import app

from .constants import LOG_TEMPLATE
from .exceptions import RepositoryError
from .exceptions import ProjectConfigurationError, RepositoryError
from .models import Domain, HTMLFile, ImportedFile, Project
from .signals import (
after_build,
Expand Down Expand Up @@ -264,6 +265,10 @@ def run(self, version_pk): # pylint: disable=arguments-differ
return False


# Exceptions under ``throws`` argument are considered ERROR from a Build
# perspective (the build failed and can continue) but as a WARNING for the
# application itself (RTD code didn't failed). These exception are logged as
# ``INFO`` and they are not sent to Sentry.
@app.task(
bind=True,
max_retries=5,
Expand All @@ -273,7 +278,11 @@ def run(self, version_pk): # pylint: disable=arguments-differ
ProjectBuildsSkippedError,
YAMLParseError,
BuildTimeoutError,
BuildEnvironmentWarning,
RepositoryError,
ProjectConfigurationError,
ProjectBuildsSkippedError,
MkDocsYAMLParseError,
),
)
def update_docs_task(self, project_id, *args, **kwargs):
Expand Down Expand Up @@ -604,8 +613,6 @@ def setup_vcs(self):
Update the checkout of the repo to make sure it's the latest.

This also syncs versions in the DB.

:param build_env: Build environment
"""
self.setup_env.update_build(state=BUILD_STATE_CLONING)

Expand All @@ -619,14 +626,17 @@ def setup_vcs(self):
try:
self.sync_repo()
except RepositoryError:
# Do not log as ERROR handled exceptions
log.warning('There was an error with the repository', exc_info=True)
# Re raise the exception to stop the build at this point
raise
except vcs_support_utils.LockTimeout:
log.info(
'Lock still active: project=%s version=%s',
self.project.slug,
self.version.slug,
)
# Raise the proper exception (won't be sent to Sentry)
raise VersionLockedError
except Exception:
# Catch unhandled errors when syncing
log.exception(
Expand All @@ -640,6 +650,8 @@ def setup_vcs(self):
},
},
)
# Re raise the exception to stop the build at this point
raise

commit = self.project.vcs_repo(self.version.slug).commit
if commit:
Expand Down Expand Up @@ -1044,7 +1056,7 @@ def symlink_project(project_pk):
sym.run()


@app.task(queue='web', throws=(BuildEnvironmentWarning,))
@app.task(queue='web')
def symlink_domain(project_pk, domain, delete=False):
"""
Symlink domain.
Expand Down Expand Up @@ -1093,7 +1105,7 @@ def broadcast_remove_orphan_symlinks():
broadcast(type='web', task=remove_orphan_symlinks, args=[])


@app.task(queue='web', throws=(BuildEnvironmentWarning,))
@app.task(queue='web')
def symlink_subproject(project_pk):
project = Project.objects.get(pk=project_pk)
for symlink in [PublicSymlink, PrivateSymlink]:
Expand Down