Skip to content

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

Merged
merged 14 commits into from
Nov 8, 2017

Conversation

ericholscher
Copy link
Member

@ericholscher ericholscher commented Nov 8, 2017

This is rebased on top of the existing search cleanup, since it was touching similar code.

Copy link
Contributor

@agjohnson agjohnson left a 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

@@ -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))
Copy link
Contributor

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.

"""
Run a broadcast across our servers.

Returns the task results for each task that was run.
Copy link
Contributor

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

tasks.append(task_sig)
if callback:
task_promise = chord(tasks)(callback).get()
log.debug('Sent Chord: {}'.format(locals()))
Copy link
Contributor

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?

Copy link
Member Author

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

log.debug('Sent Chord: {}'.format(locals()))
else:
task_promise = group(*tasks).apply_async()
log.debug('Sent Group: {}'.format(locals()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

@@ -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'
Copy link
Contributor

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.

Copy link
Member Author

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?

@@ -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'] = []
Copy link
Contributor

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?

Copy link
Member Author

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
@ericholscher ericholscher merged commit 2ac95a9 into master Nov 8, 2017
@agjohnson agjohnson deleted the better-sync-reporting branch November 8, 2017 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants