Cscott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/284601

Change subject: Allow decommissioning OCG hosts.
......................................................................

Allow decommissioning OCG hosts.

A decommissioned host will answer frontend requests but not take new
backend jobs from the redis queue.  This allows us to remove its
cached jobs from redis (either proactively or by timing them out),
after which it should receive no further frontend requests and can
be shut down.

For cluster failover, the "backup" hosts on the secondary cluster can
all be listed as decommissioned using a regexp until they are needed.

Bug: T120077
Change-Id: I5b8388ac914a2129f8346ee3f4932455fa14c8e4
---
M defaults.js
M mw-ocg-service.js
2 files changed, 17 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator
 refs/changes/01/284601/1

diff --git a/defaults.js b/defaults.js
index a97637a..3355ec3 100644
--- a/defaults.js
+++ b/defaults.js
@@ -24,6 +24,11 @@
                /** Public hostname of this instance for HTTP GET requests for 
locally stored content. */
                hostname: null,
 
+               /** Array of strings or regular expressions naming hosts which
+                *  should be "decommissioned" --- that is, they should not
+                *  launch backend threads. */
+               decommission: [],
+
                /** How often (in seconds) to check for configuration changes.
                 * We gracefully shutdown when we get a config change; 
presumably
                 * upstart or some other service runner will restart us.  
Defaults
diff --git a/mw-ocg-service.js b/mw-ocg-service.js
index e140ee6..c702c48 100755
--- a/mw-ocg-service.js
+++ b/mw-ocg-service.js
@@ -182,6 +182,18 @@
        if (autoThreads === 'auto') {
                autoThreads = os.cpus().length;
        }
+       // Check: is this host decommissioned?  If so, don't launch any
+       // background threads.
+       var host = config.coordinator.hostname || os.hostname();
+       var decommission = config.coordinator.decommission;
+       if (!Array.isArray(decommission)) { decommission = [ decommission ]; }
+       if (decommission.some(function(s) {
+               // s could be a string or a regular expression
+               return host===s || (s.test && s.test(host));
+       })) {
+               console.warn('%s decommissioned; no backend threads launched.', 
host);
+               autoThreads = 0;
+       }
        for (i = 0; i < autoThreads; i++) {
                spawnWorker('backend');
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/284601
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5b8388ac914a2129f8346ee3f4932455fa14c8e4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator
Gerrit-Branch: master
Gerrit-Owner: Cscott <canan...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to