C. Scott Ananian has uploaded a new change for review. https://gerrit.wikimedia.org/r/313876
Change subject: Allow administrators to blacklist renders of certain metabooks. ...................................................................... Allow administrators to blacklist renders of certain metabooks. This is a ham-handed but hopefully effective way to deal with denial of service/abuse. Bug: T147211 Change-Id: I4c1c3e155e399dc80d501aa9d8ee286f23a92db4 --- M lib/threads/frontend.js 1 file changed, 17 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator refs/changes/76/313876/1 diff --git a/lib/threads/frontend.js b/lib/threads/frontend.js index c67ba94..617d37f 100644 --- a/lib/threads/frontend.js +++ b/lib/threads/frontend.js @@ -569,6 +569,11 @@ * @returns {bool|Promise} */ var canIRender = Promise.method(function() { + if (config.frontend.blacklist instanceof RegExp && metabookObj) { + if (config.frontend.blacklist.exec(JSON.stringify(metabookObj))) { + return [false, 'Administrative blacklist.']; + } + } if (config.redis.max_job_queue_length) { return redisClient .llen(config.redis.job_queue_name) @@ -579,10 +584,13 @@ job: { id: collectionId }, }); statsd.gauge('job_queue_length', len); - return len <= config.redis.max_job_queue_length; + return [ + len <= config.redis.max_job_queue_length, + 'Job queue is full' + ]; }); } else { - return true; + return [true, 'Success.']; } }); @@ -625,16 +633,17 @@ return determineCachedStatus().then(function(cacheStatus) { isCached = cacheStatus; if (!isCached) { - return canIRender().then(function(canRender) { - if (canRender) { - return addRenderJob(); - } else { - console.warn('Refusing new job because job queue is full', { + return canIRender().spread(function(canRender, whyNot) { + whyNot = whyNot || "Unknown reason."; + if (canRender) { + return addRenderJob(); + } else { + console.warn('Refusing new job because: '+whyNot, { channel: 'frontend', request: { id: requestId }, job: { id: collectionId }, }); - throw new FrontendError(503, 'Job queue is full.'); + throw new FrontendError(503, whyNot); } }); } else { -- To view, visit https://gerrit.wikimedia.org/r/313876 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4c1c3e155e399dc80d501aa9d8ee286f23a92db4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator Gerrit-Branch: master Gerrit-Owner: C. Scott Ananian <canan...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits