Skip to content

Don't log BuildEnvironmentWarning as error #6112

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 2 commits into from
Sep 5, 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
13 changes: 10 additions & 3 deletions readthedocs/vcs_support/base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-

"""Base classes for VCS backends."""
import logging
import os
import shutil

from readthedocs.doc_builder.exceptions import BuildEnvironmentWarning
from readthedocs.projects.exceptions import RepositoryError


log = logging.getLogger(__name__)

Expand Down Expand Up @@ -102,7 +103,13 @@ def run(self, *cmd, **kwargs):
'shell': False,
})

build_cmd = self.environment.run(*cmd, **kwargs)
try:
build_cmd = self.environment.run(*cmd, **kwargs)
except BuildEnvironmentWarning as e:
Copy link
Member

Choose a reason for hiding this comment

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

It is supposed that we are not logging BuildEnvironmentWarning already (

BuildEnvironmentWarning,
). I'm not sure to follow why catching this exception and re-raising it as RepositoyError will avoid the log in Sentry.

I feel confused here 😕

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but that isn't the cause. We are logging it manually here

except Exception:
# Catch unhandled errors when syncing
log.exception(
'An unhandled exception was raised during VCS syncing',
extra={
'stack': True,
'tags': {
'project': self.project.slug,
'version': self.version.slug,
},
},
)

That try...except block only captures RepositoryError and LockTimeout, everything else is logged

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha! Do you know why the sync_repo is not ran inside the context manager that manages all the exceptions in the __exit__ as we do run all the rest of the commands?

Copy link
Member Author

Choose a reason for hiding this comment

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

It runs inside one

with self.setup_env:
try:
before_vcs.send(sender=self.version)
if self.project.skip:
raise ProjectBuildsSkippedError
try:
with self.project.repo_nonblockinglock(version=self.version):
self.setup_vcs()

But again, that's not the problem. We still log the exception to sentry manually.

Copy link
Member

Choose a reason for hiding this comment

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

I'm talking about this one which does not seem to be ran inside a context manager:

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really sure, we don't record that action as a build, so we don't need the all the stuff from the context manager. It doesn't seen related to this anyway. Both calls use the default env

self.environment = environment or LocalEnvironment(project)
and don't use the context manager.

Copy link
Member

Choose a reason for hiding this comment

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

Let's merge and see what happen after the next deploy :)

# Re raise as RepositoryError,
# so isn't logged as ERROR.
raise RepositoryError(str(e))

# Return a tuple to keep compatibility
return (build_cmd.exit_code, build_cmd.output, build_cmd.error)

Expand Down