-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Do some initial file syncing error handling cleanup #3235
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks solid, and seems there are potentially a number of cases that we'll at least be reporting on instead of dropping during the build process
readthedocs/builds/syncers.py
Outdated
@@ -140,7 +140,8 @@ def copy(cls, path, target, host, is_file=False, **__): | |||
) | |||
ret = os.system(sync_cmd) | |||
if ret != 0: | |||
log.info("COPY ERROR to app servers.") | |||
log.error("COPY ERROR to app servers. Return code: {}".format(ret)) | |||
log.error("COPY ERROR command run: {}".format(sync_cmd)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One log line would be better here, so we're not splitting reporting up into two line/pieces to sentry.
readthedocs/core/utils/__init__.py
Outdated
""" | ||
Run a broadcast across our servers. | ||
|
||
Returns the task results for each task that was run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to explain callback
usage here as well
readthedocs/core/utils/__init__.py
Outdated
tasks.append(task_sig) | ||
if callback: | ||
task_promise = chord(tasks)(callback).get() | ||
log.debug('Sent Chord: {}'.format(locals())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can't guarantee that locals()
won't leak things we don't want logged to logging, I'd say this should instead be logging some interpretation of the task name and what was passed in. Perhaps task name + kwarg names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just kill this, as celery with debug logging will show the tasks in console
readthedocs/core/utils/__init__.py
Outdated
log.debug('Sent Chord: {}'.format(locals())) | ||
else: | ||
task_promise = group(*tasks).apply_async() | ||
log.debug('Sent Group: {}'.format(locals())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
readthedocs/settings/dev.py
Outdated
@@ -55,6 +56,8 @@ def DATABASES(self): # noqa | |||
def LOGGING(self): # noqa - avoid pep8 N802 | |||
logging = super(CommunityDevSettings, self).LOGGING | |||
logging['formatters']['default']['format'] = '[%(asctime)s] ' + self.LOG_FORMAT | |||
logging['handlers']['console']['level'] = 'DEBUG' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want debug logs spamming the console? @humitos and I talked on this a while back and decided that moving DEBUG level logs to a file avoids overwhelming users. I'm -0 on moving back to the console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I found it easier to deal with, but that's fine as long as we know it is a convention. Is that what debug.log is for?
readthedocs/settings/dev.py
Outdated
@@ -55,6 +56,8 @@ def DATABASES(self): # noqa | |||
def LOGGING(self): # noqa - avoid pep8 N802 | |||
logging = super(CommunityDevSettings, self).LOGGING | |||
logging['formatters']['default']['format'] = '[%(asctime)s] ' + self.LOG_FORMAT | |||
logging['handlers']['console']['level'] = 'DEBUG' | |||
logging['loggers']['']['handlers'] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this remove the double logging on development?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea.
diff --git a/readthedocs/builds/syncers.py b/readthedocs/builds/syncers.py index 7b61bb6..3c8af91 100644 --- a/readthedocs/builds/syncers.py +++ b/readthedocs/builds/syncers.py @@ -140,8 +140,7 @@ class RemotePuller(object): ) ret = os.system(sync_cmd) if ret != 0: - log.error("COPY ERROR to app servers. Return code: {}".format(ret)) - log.error("COPY ERROR command run: {}".format(sync_cmd)) + log.error("COPY ERROR to app servers. Command: [{}] Return: [{}]".format(sync_cmd, ret)) class Syncer(SettingsOverrideObject): diff --git a/readthedocs/core/utils/__init__.py b/readthedocs/core/utils/__init__.py index 10d8656..fca8e13 100644 --- a/readthedocs/core/utils/__init__.py +++ b/readthedocs/core/utils/__init__.py @@ -30,7 +30,10 @@ def broadcast(type, task, args, kwargs=None, callback=None): # pylint: disable= """ Run a broadcast across our servers. - Returns the task results for each task that was run. + Returns a task group that can be checked for results. + + `callback` should be a task signature that will be run once, + after all of the broadcast tasks have finished running. """ assert type in ['web', 'app', 'build'] if kwargs is None: @@ -47,10 +50,8 @@ def broadcast(type, task, args, kwargs=None, callback=None): # pylint: disable= tasks.append(task_sig) if callback: task_promise = chord(tasks)(callback).get() - log.debug('Sent Chord: {}'.format(locals())) else: task_promise = group(*tasks).apply_async() - log.debug('Sent Group: {}'.format(locals())) return task_promise diff --git a/readthedocs/settings/dev.py b/readthedocs/settings/dev.py index 8c39e12..e605f2c 100644 --- a/readthedocs/settings/dev.py +++ b/readthedocs/settings/dev.py @@ -56,7 +56,7 @@ class CommunityDevSettings(CommunityBaseSettings): def LOGGING(self): # noqa - avoid pep8 N802 logging = super(CommunityDevSettings, self).LOGGING logging['formatters']['default']['format'] = '[%(asctime)s] ' + self.LOG_FORMAT - logging['handlers']['console']['level'] = 'DEBUG' + # Remove double logging logging['loggers']['']['handlers'] = [] return logging
This is rebased on top of the existing search cleanup, since it was touching similar code.