Clean up some logging and remove old settings. No going back now.
This commit is contained in:
Родитель
e5cdbc74cf
Коммит
cfd4675f13
|
@ -1105,8 +1105,6 @@ def version_changed(sender, **kw):
|
|||
dispatch_uid='addons.search.index')
|
||||
def update_search_index(sender, instance, **kw):
|
||||
from . import tasks
|
||||
if settings.SKIP_SEARCH_INDEX:
|
||||
return
|
||||
|
||||
if not kw.get('raw'):
|
||||
tasks.index_addons.delay([instance.id])
|
||||
|
@ -1116,8 +1114,6 @@ def update_search_index(sender, instance, **kw):
|
|||
dispatch_uid='addons.search.unindex')
|
||||
def delete_search_index(sender, instance, **kw):
|
||||
from . import tasks
|
||||
if settings.SKIP_SEARCH_INDEX:
|
||||
return
|
||||
|
||||
if not kw.get('raw'):
|
||||
tasks.unindex_addons.delay([instance.id])
|
||||
|
|
|
@ -92,8 +92,6 @@ def delete_preview_files(id, **kw):
|
|||
|
||||
@task
|
||||
def index_addons(ids, **kw):
|
||||
if not settings.USE_ELASTIC:
|
||||
return
|
||||
es = elasticutils.get_es()
|
||||
log.info('Indexing addons %s-%s. [%s]' % (ids[0], ids[-1], len(ids)))
|
||||
qs = Addon.uncached.filter(id__in=ids)
|
||||
|
@ -141,8 +139,6 @@ def attach_tags(addons):
|
|||
|
||||
@task
|
||||
def unindex_addons(ids, **kw):
|
||||
if not settings.USE_ELASTIC:
|
||||
return
|
||||
for addon in ids:
|
||||
log.info('Removing addon [%s] from search index.' % addon)
|
||||
Addon.unindex(addon)
|
||||
|
|
|
@ -88,15 +88,13 @@ def libraries():
|
|||
|
||||
def elastic():
|
||||
elastic_results = None
|
||||
status = True
|
||||
if settings.USE_ELASTIC:
|
||||
status = False
|
||||
try:
|
||||
health = elasticutils.get_es().cluster_health()
|
||||
status = health['status'] != 'red'
|
||||
elastic_results = health
|
||||
except Exception:
|
||||
elastic_results = traceback.format_exc()
|
||||
status = False
|
||||
try:
|
||||
health = elasticutils.get_es().cluster_health()
|
||||
status = health['status'] != 'red'
|
||||
elastic_results = health
|
||||
except Exception:
|
||||
elastic_results = traceback.format_exc()
|
||||
|
||||
return status, elastic_results
|
||||
|
||||
|
|
|
@ -103,7 +103,6 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
{% if settings.USE_ELASTIC %}
|
||||
<div class="notification-box {{ status(status_summary.elastic) }}">
|
||||
<h2>[Elastic Search] Health Check ({{ elastic_timer }}ms)</h2>
|
||||
<ul>
|
||||
|
@ -118,6 +117,5 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock main_content %}
|
||||
|
|
|
@ -306,7 +306,6 @@ class ESTestCase(TestCase):
|
|||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.es = elasticutils.get_es()
|
||||
settings.USE_ELASTIC = True
|
||||
|
||||
if ESTestCase.use_es is None:
|
||||
for key, index in settings.ES_INDEXES.items():
|
||||
|
@ -337,7 +336,6 @@ class ESTestCase(TestCase):
|
|||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
settings.USE_ELASTIC = False
|
||||
# Delete everything in reverse-order of the foriegn key dependencies.
|
||||
models = (Platform, File, ApplicationsVersions, Version,
|
||||
Translation, Addon, AppVersion, Application)
|
||||
|
|
|
@ -108,10 +108,8 @@ def cron_collection_meta(*addons, **kw):
|
|||
|
||||
@task
|
||||
def index_collections(ids, **kw):
|
||||
if not settings.USE_ELASTIC:
|
||||
return
|
||||
es = elasticutils.get_es()
|
||||
log.info('Indexing collections %s-%s [%s].' % (ids[0], ids[-1], len(ids)))
|
||||
log.debug('Indexing collections %s-%s [%s].' % (ids[0], ids[-1], len(ids)))
|
||||
for c in Collection.objects.filter(id__in=ids):
|
||||
Collection.index(search.extract(c), bulk=True, id=c.id)
|
||||
es.flush_bulk(forced=True)
|
||||
|
@ -119,8 +117,6 @@ def index_collections(ids, **kw):
|
|||
|
||||
@task
|
||||
def unindex_collections(ids, **kw):
|
||||
if not settings.USE_ELASTIC:
|
||||
return
|
||||
for id in ids:
|
||||
log.info('Removing collection [%s] from search index.' % id)
|
||||
log.debug('Removing collection [%s] from search index.' % id)
|
||||
Collection.unindex(id)
|
||||
|
|
|
@ -23,7 +23,7 @@ def cleanup_extracted_file():
|
|||
full = os.path.join(root, path)
|
||||
age = time.time() - os.stat(full)[stat.ST_ATIME]
|
||||
if (age) > (60 * 60):
|
||||
log.info('Removing extracted files: %s, %dsecs old.' % (full, age))
|
||||
log.debug('Removing extracted files: %s, %dsecs old.' % (full, age))
|
||||
shutil.rmtree(full)
|
||||
# Nuke out the file and diff caches when the file gets removed.
|
||||
id = os.path.basename(path)
|
||||
|
@ -36,7 +36,6 @@ def cleanup_extracted_file():
|
|||
key.update(str(id))
|
||||
cache.delete('%s:memoize:%s:%s' % (settings.CACHE_PREFIX,
|
||||
'file-viewer', key.hexdigest()))
|
||||
log.info('Removing cache file-viewer cache entries for: %s' % id)
|
||||
|
||||
|
||||
@cronjobs.register
|
||||
|
|
|
@ -408,18 +408,18 @@ class File(amo.models.OnChangeMixin, amo.models.ModelBase):
|
|||
with amo.utils.guard('marketplace.watermark.%s' % dest) as locked:
|
||||
if locked:
|
||||
# The calling method will need to do something about this.
|
||||
log.error('Watermarking in progress of: %s for %s' %
|
||||
log.error('Watermarking collision: %s for %s' %
|
||||
(self.pk, user.pk))
|
||||
return
|
||||
|
||||
if os.path.exists(dest):
|
||||
age = time.time() - os.stat(dest)[stat.ST_ATIME]
|
||||
if age > settings.WATERMARK_REUSE_SECONDS:
|
||||
log.info('Removing stale watermark %s for %s %dsecs.' %
|
||||
log.debug('Removing stale watermark %s for %s %dsecs.' %
|
||||
(self.pk, user.pk, age))
|
||||
os.remove(dest)
|
||||
else:
|
||||
log.info('Already watermarked: %s for %s' %
|
||||
log.debug('Reusing existing watermarked file: %s for %s' %
|
||||
(self.pk, user.pk))
|
||||
# Touch the update time so that the cron job won't delete
|
||||
# us too quickly.
|
||||
|
|
|
@ -37,7 +37,7 @@ def extract_file(viewer, **kw):
|
|||
msg.delete()
|
||||
# This flag is so that we can signal when the extraction is completed.
|
||||
flag = Message(viewer._extraction_cache_key())
|
||||
task_log.info('[1@%s] Unzipping %s for file viewer.' % (
|
||||
task_log.debug('[1@%s] Unzipping %s for file viewer.' % (
|
||||
extract_file.rate_limit, viewer))
|
||||
|
||||
try:
|
||||
|
@ -59,7 +59,7 @@ def migrate_jetpack_versions(ids, **kw):
|
|||
# TODO(jbalogh): kill in bug 656997
|
||||
for file_ in File.objects.filter(id__in=ids):
|
||||
file_.jetpack_version = File.get_jetpack_version(file_.file_path)
|
||||
task_log.info('Setting jetpack version to %s for File %s.' %
|
||||
task_log.debug('Setting jetpack version to %s for File %s.' %
|
||||
(file_.jetpack_version, file_.id))
|
||||
file_.save()
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ task_log = commonware.log.getLogger('z.task')
|
|||
|
||||
@task
|
||||
def delete_photo(dst, **kw):
|
||||
task_log.info('[1@None] Deleting photo: %s.' % dst)
|
||||
task_log.debug('[1@None] Deleting photo: %s.' % dst)
|
||||
|
||||
if not dst.startswith(settings.USERPICS_PATH):
|
||||
task_log.error("Someone tried deleting something they shouldn't: %s"
|
||||
|
@ -34,7 +34,7 @@ def delete_photo(dst, **kw):
|
|||
@set_modified_on
|
||||
def resize_photo(src, dst, **kw):
|
||||
"""Resizes userpics to 200x200"""
|
||||
task_log.info('[1@None] Resizing photo: %s' % dst)
|
||||
task_log.debug('[1@None] Resizing photo: %s' % dst)
|
||||
|
||||
try:
|
||||
resize_image(src, dst, (200, 200))
|
||||
|
@ -45,10 +45,8 @@ def resize_photo(src, dst, **kw):
|
|||
|
||||
@task
|
||||
def index_users(ids, **kw):
|
||||
if not settings.USE_ELASTIC:
|
||||
return
|
||||
es = elasticutils.get_es()
|
||||
task_log.info('Indexing users %s-%s [%s].' % (ids[0], ids[-1], len(ids)))
|
||||
task_log.debug('Indexing users %s-%s [%s].' % (ids[0], ids[-1], len(ids)))
|
||||
for c in UserProfile.objects.filter(id__in=ids):
|
||||
UserProfile.index(search.extract(c), bulk=True, id=c.id)
|
||||
es.flush_bulk(forced=True)
|
||||
|
@ -56,10 +54,8 @@ def index_users(ids, **kw):
|
|||
|
||||
@task
|
||||
def unindex_users(ids, **kw):
|
||||
if not settings.USE_ELASTIC:
|
||||
return
|
||||
for id in ids:
|
||||
task_log.info('Removing user [%s] from search index.' % id)
|
||||
task_log.debug('Removing user [%s] from search index.' % id)
|
||||
UserProfile.unindex(id)
|
||||
|
||||
|
||||
|
|
|
@ -37,9 +37,6 @@ DEBUG_PROPAGATE_EXCEPTIONS = True
|
|||
# then connect to <yourhost>:8080 to view
|
||||
REMOTE_JS_DEBUG = False
|
||||
|
||||
# Skip indexing ES to speed things up?
|
||||
SKIP_SEARCH_INDEX = False
|
||||
|
||||
# LESS CSS OPTIONS (Debug only)
|
||||
LESS_PREPROCESS = False # Compile LESS with Node, rather than client-side JS?
|
||||
LESS_LIVE_REFRESH = False # Refresh the CSS on save?
|
||||
|
@ -1208,8 +1205,8 @@ ARECIBO_SETTINGS = {
|
|||
# successfully logging in or out.
|
||||
VALID_LOGIN_REDIRECTS = {
|
||||
'builder': 'https://builder.addons.mozilla.org',
|
||||
'builderstage': 'https://builder-addons-next.allizom.org',
|
||||
'buildertrunk': 'https://builder-addons.allizom.org',
|
||||
'builderstage': 'https://builder-addons.allizom.org',
|
||||
'buildertrunk': 'https://builder-addons-dev.allizom.org',
|
||||
}
|
||||
|
||||
# Secret key we send to builder so we can trust responses from the builder.
|
||||
|
@ -1225,7 +1222,6 @@ ES_INDEXES = {'default': 'amo',
|
|||
'update_counts': 'amo_stats',
|
||||
'download_counts': 'amo_stats'}
|
||||
ES_TIMEOUT = 5
|
||||
USE_ELASTIC = True
|
||||
|
||||
# Default AMO user id to use for tasks.
|
||||
TASK_USER_ID = 4757633
|
||||
|
|
Загрузка…
Ссылка в новой задаче