From 2a7f17e387991d18cccfbe5ed0d49fbe04f17926 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Thu, 2 Apr 2020 13:01:15 +0200 Subject: [PATCH] Add more exceptions as WARNING log level `RepositoryError` and `ProjectConfigurationError` are user errors that we should not log as ERROR, but as WARNING instead. Also, the `throws` list is removed here since all these exceptions happen inside the Build Environment who already manage them in the `__exit__` method and so, they are never seen by the task. --- readthedocs/doc_builder/environments.py | 13 ++++++++++--- readthedocs/projects/tasks.py | 20 ++++---------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/readthedocs/doc_builder/environments.py b/readthedocs/doc_builder/environments.py index 6f70d51a232..2efe46d667a 100644 --- a/readthedocs/doc_builder/environments.py +++ b/readthedocs/doc_builder/environments.py @@ -26,6 +26,10 @@ from readthedocs.core.utils import slugify from readthedocs.projects.constants import LOG_TEMPLATE from readthedocs.projects.models import Feature +from readthedocs.projects.exceptions import ( + RepositoryError, + ProjectConfigurationError, +) from .constants import ( DOCKER_HOSTNAME_MAX_LEN, @@ -528,15 +532,18 @@ class BuildEnvironment(BaseEnvironment): successful """ - # Exceptions considered ERROR from a Build perspective but as a WARNING for - # the application itself. These exception are logged as warning and not sent - # to Sentry. + # These exceptions 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 ``WARNING`` and they + # are not sent to Sentry. WARNING_EXCEPTIONS = ( VersionLockedError, ProjectBuildsSkippedError, YAMLParseError, BuildTimeoutError, MkDocsYAMLParseError, + RepositoryError, + ProjectConfigurationError, ) def __init__( diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py index 70082612835..5cfb3365c2e 100644 --- a/readthedocs/projects/tasks.py +++ b/readthedocs/projects/tasks.py @@ -307,7 +307,10 @@ def get_rtd_env_vars(self): return env -@app.task(max_retries=5, default_retry_delay=7 * 60) +@app.task( + max_retries=5, + default_retry_delay=7 * 60, +) def sync_repository_task(version_pk): """Celery task to trigger VCS version sync.""" try: @@ -394,25 +397,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, default_retry_delay=7 * 60, - throws=( - VersionLockedError, - ProjectBuildsSkippedError, - YAMLParseError, - BuildTimeoutError, - BuildEnvironmentWarning, - RepositoryError, - ProjectConfigurationError, - ProjectBuildsSkippedError, - MkDocsYAMLParseError, - ), ) def update_docs_task(self, version_pk, *args, **kwargs): try: