Giuseppe Lavagetto has uploaded a new change for review.

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

Change subject: Rationalize definition of service hosts
......................................................................

Rationalize definition of service hosts

Since we have multiple hosts we need to connect to, and those might (or
might not) change based on the datacenter, define four variables:

* wmfMasterDatacenter - indicating the master datacenter
* wmfAllServices - a list of hosts for all datacenters
* wmfLocalServices - service hosts local to the current datacenter
* wmfMasterServices - service hosts in the master datacenter

Also use references to said variables in CommonSettings.php

Bug: T114273
Change-Id: I096b4388cde644b1bbcbb53a71a36495ee62c5f5
---
M wmf-config/CommonSettings.php
A wmf-config/ProductionServices.php
2 files changed, 59 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/09/266509/1

diff --git a/wmf-config/CommonSettings.php b/wmf-config/CommonSettings.php
index 2750166..413992b 100644
--- a/wmf-config/CommonSettings.php
+++ b/wmf-config/CommonSettings.php
@@ -43,6 +43,10 @@
 
 set_include_path( "$IP:/usr/local/lib/php:/usr/share/php" );
 
+# Master datacenter
+# The datacenter from which we serve traffic.
+$wmfMasterDatacenter = 'eqiad';
+
 ### List of some service hostnames
 # 'meta'    : meta wiki for user editable content
 # 'upload'  : hostname where files are hosted
@@ -80,10 +84,15 @@
 # wmf-config directory (in common/)
 $wmfConfigDir = "$IP/../wmf-config";
 
+# Include all the service definitions, if in production
+if ( $wmfRealm == 'production' ) {
+       require "$wmfConfigDir/ProductionServices.php";
+}
+
 # Must be set before InitialiseSettings.php:
 switch( $wmfRealm ) {
 case 'production':
-       $wmfUdp2logDest = 'fluorine.eqiad.wmnet:8420';
+       $wmfUdp2logDest = $wmfLocalServices['udp2log'];
        break;
 case 'labs':
        $wmfUdp2logDest = 'deployment-fluorine.eqiad.wmflabs:8420';
@@ -449,7 +458,7 @@
 #######################################################################
 
 if ( $wmfRealm === 'production' ) {
-       $wgStatsdServer = 'statsd.eqiad.wmnet';
+       $wgStatsdServer = $wmfLocalServices['statsd'];
        if ( $wmgUseClusterSquid ) {
                $wgUseSquid = true;
                require( "$wmfConfigDir/squid.php" );
@@ -1294,7 +1303,7 @@
        $wgApiFeatureUsageQueryEngineConf = array(
                'class' => 'ApiFeatureUsageQueryEngineElastica',
                'serverList' => array(
-                       '10.2.2.30', # search.svc.eqiad.wmnet
+                       $wmfLocalServices['search'], # search.svc.eqiad.wmnet
                ),
        );
 }
@@ -1567,10 +1576,10 @@
 if ( $wmgUseCollection ) {
        // PediaPress / PDF generation
        include "$IP/extensions/Collection/Collection.php";
-       $wgCollectionMWServeURL = 'http://ocg.svc.eqiad.wmnet:8000';
+       $wgCollectionMWServeURL = "http://{$wmfLocalServices['ocg']}:8000";
        // Use pediapress server for POD function (T73675)
        $wgCollectionCommandToServeURL = array(
-               'zip_post' => 
'http://url-downloader.wikimedia.org:8080|https://pediapress.com/wmfup/',
+               'zip_post' => 
"http://{$wmfLocalServices['urldownloader']}:8080|https://pediapress.com/wmfup/";,
        );
        $wgCollectionPODPartners = array(
                'pediapress' => array(
@@ -1956,7 +1965,7 @@
 }
 
 if ( $wmgUseParsoid ) {
-       $wmgParsoidURL = 'http://10.2.2.29'; // parsoidcache.svc.eqiad.wmnet
+       $wmgParsoidURL = $wmfMasterServices['parsoidcache']; // 
parsoidcache.svc.eqiad.wmnet
 
        // The wiki prefix to use
        $wgParsoidWikiPrefix = $wgDBname; // deprecated
@@ -2173,7 +2182,7 @@
        // This variable points to non-WMF servers by default.
        // Prevent accidental use.
        $wgMathLaTeXMLUrl = null;
-       $wgMathMathMLUrl = "http://mathoid.svc.eqiad.wmnet:10042";;
+       $wgMathMathMLUrl = "http://{$wmfLocalServices['mathoid']}:10042";
 
        // Set up $wgMathFullRestbaseURL - similar to VE RESTBase config above
        // HACK: $wgServerName is not available yet at this point, it's set by 
Setup.php
@@ -2677,7 +2686,7 @@
                // All other wikis reference metawiki.
                $wgEventLoggingBaseUri = "{$wgServer}/beacon/event";
                $wgEventLoggingDBname = 'metawiki';
-               $wgEventLoggingFile = 'udp://10.64.32.167:8421/EventLogging';  
// eventlog1001.eqiad.wmnet
+               $wgEventLoggingFile = 
"udp://{$wmfLocalServices['eventlogging']}:8421/EventLogging";  // 
eventlog1001.eqiad.wmnet
                $wgEventLoggingSchemaApiUri = 
'https://meta.wikimedia.org/w/api.php';
        }
        if ( $wgEventLoggingDBname === $wgDBname ) {
@@ -3079,7 +3088,7 @@
 
 if ( $wmgUseEventBus ) {
        wfLoadExtension( 'EventBus' );
-       $wgEventServiceUrl = 'http://eventbus.svc.eqiad.wmnet:8085/v1/events';
+       $wgEventServiceUrl = 
"http://{$wmfMasterServices['eventbus']}:8085/v1/events";
 }
 
 # THIS MUST BE AFTER ALL EXTENSIONS ARE INCLUDED
diff --git a/wmf-config/ProductionServices.php 
b/wmf-config/ProductionServices.php
new file mode 100644
index 0000000..863e370
--- /dev/null
+++ b/wmf-config/ProductionServices.php
@@ -0,0 +1,41 @@
+<?php
+# WARNING: This file is publically viewable on the web. Do not put private 
data here.
+
+#######################################################################
+# ProductionServices.php should include all the service hostnames/ips
+# for any service used in production, divided by datacenter.
+#
+# It is included by CommonSettings.php
+#
+#######################################################################
+
+$wmfAllServices = array();
+
+$wmfAllServices['eqiad'] = array(
+       'udp2log' => 'fluorine.eqiad.wmnet:8420',
+       'statsd' => 'statsd.eqiad.wmnet',
+       'search' => '10.2.2.30',
+       'ocg' => 'ocg.svc.eqiad.wmnet',
+       'urldownloader' => 'url-downloader.wikimedia.org',
+       'parsoidcache' => '10.2.2.29',
+       'mathoid' => 'mathoid.svc.eqiad.wmnet',
+       'eventlogging' => '10.64.32.167',
+       'eventbus' => 'eventbus.svc.eqiad.wmnet',
+);
+
+$wmfAllServices['codfw'] = array(
+       'udp2log' => 'fluorine.eqiad.wmnet:8420',
+       'statsd' => 'statsd.eqiad.wmnet',
+       'search' => '10.2.1.30',
+       'ocg' => 'ocg.svc.eqiad.wmnet',
+       'urldownloader' => 'url-downloader.wikimedia.org',
+       'parsoidcache' => '10.2.2.29', # Change this once parsoidcache is up 
and running in codfw
+       'mathoid' => 'mathoid.svc.eqiad.wmnet',
+       'eventlogging' => '10.64.32.167',
+       'eventbus' => 'eventbus.svc.eqiad.wmnet',
+);
+
+# Shorthand when we have no master-slave situation to keep into account
+$wmfLocalServices = $wmfAllServices[$wmfDatacenter];
+
+$wmfMasterServices = $wmfAllServices[$wmfMasterDatacenter];

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I096b4388cde644b1bbcbb53a71a36495ee62c5f5
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Giuseppe Lavagetto <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to