jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/347537 )

Change subject: Use EtcdConfig in beta cluster only
......................................................................


Use EtcdConfig in beta cluster only

Prototype for production deployment.

Fetch $wgReadOnly and $wmfMasterDatacenter from etcd. Avoid MultiConfig
for now, to avoid slowing down Config::get() calls.

Bug: T156924
Bug: T163398
Change-Id: I23d4e7da0544e27bb3a4ad84f6f2ef195162fb2c
---
A docroot/noc/conf/etcd.php.txt
M docroot/noc/createTxtFileSymlinks.sh
M wmf-config/CommonSettings.php
M wmf-config/InitialiseSettings.php
M wmf-config/LabsServices.php
M wmf-config/ProductionServices.php
A wmf-config/etcd.php
7 files changed, 62 insertions(+), 24 deletions(-)

Approvals:
  Tim Starling: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/docroot/noc/conf/etcd.php.txt b/docroot/noc/conf/etcd.php.txt
new file mode 120000
index 0000000..173e8a7
--- /dev/null
+++ b/docroot/noc/conf/etcd.php.txt
@@ -0,0 +1 @@
+../../../wmf-config/etcd.php
\ No newline at end of file
diff --git a/docroot/noc/createTxtFileSymlinks.sh 
b/docroot/noc/createTxtFileSymlinks.sh
index db9fa37..982aca1 100755
--- a/docroot/noc/createTxtFileSymlinks.sh
+++ b/docroot/noc/createTxtFileSymlinks.sh
@@ -17,6 +17,7 @@
        db-codfw.php
        db-eqiad.php
        db-labs.php
+       etcd.php
        FeaturedFeedsWMF.php
        filebackend.php
        flaggedrevs.php
diff --git a/wmf-config/CommonSettings.php b/wmf-config/CommonSettings.php
index 839e219..2794a57 100644
--- a/wmf-config/CommonSettings.php
+++ b/wmf-config/CommonSettings.php
@@ -51,10 +51,6 @@
 
 set_include_path( "$IP:/usr/local/lib/php:/usr/share/php" );
 
-# Master datacenter
-# The datacenter from which we serve traffic.
-$wmfMasterDatacenter = 'codfw';
-
 ### List of some service hostnames
 # 'meta'    : meta wiki for user editable content
 # 'upload'  : hostname where files are hosted
@@ -100,6 +96,19 @@
        require "$wmfConfigDir/ProductionServices.php";
 }
 
+# Shorthand when we have no master-slave situation to keep into account
+$wmfLocalServices = $wmfAllServices[$wmfDatacenter];
+
+# Labs-only for testing, eventually etcd.php will be used in production as well
+if ( $wmfRealm === 'labs' ) {
+       # Get configuration from etcd. This gives us the correct 
$wmfMasterDatacenter
+       require "$wmfConfigDir/etcd.php";
+} else {
+       $wmfMasterDatacenter = 'codfw';
+}
+
+$wmfMasterServices = $wmfAllServices[$wmfMasterDatacenter];
+
 # Must be set before InitialiseSettings.php:
 $wmfUdp2logDest = $wmfLocalServices['udp2log'];
 
diff --git a/wmf-config/InitialiseSettings.php 
b/wmf-config/InitialiseSettings.php
index fdee8f9..775e521 100644
--- a/wmf-config/InitialiseSettings.php
+++ b/wmf-config/InitialiseSettings.php
@@ -4765,14 +4765,6 @@
        'wikivoyage' => 'wikivoyage',
 ],
 
-'wgReadOnly' => [
-       'default' => null,
-],
-
-'wgReadOnlyFile' => [
-       'default' => false,
-],
-
 # wgTranslateNumerals @{
 'wgTranslateNumerals' => [
        'default' => true,
diff --git a/wmf-config/LabsServices.php b/wmf-config/LabsServices.php
index 4476505..5453d95 100644
--- a/wmf-config/LabsServices.php
+++ b/wmf-config/LabsServices.php
@@ -33,6 +33,7 @@
                'rdb1' => '10.68.16.177', // 
deployment-redis01.deployment-prep.eqiad.wmflabs
                'rdb2' => '10.68.16.231', // 
deployment-redis02.deployment-prep.eqiad.wmflabs
        ],
+       'etcd' => 'deployment-etcd-01.deployment-prep.eqiad.wmflabs:2379',
 ];
 
 ### Logstash
@@ -53,9 +54,3 @@
 $wmfAllServices['eqiad']['poolcounter'] = [
        '10.68.17.48', # deployment-poolcounter04.deployment-prep.eqiad.wmflabs
 ];
-
-
-# Shorthand when we have no master-slave situation to keep into account
-$wmfLocalServices = $wmfAllServices['eqiad'];
-
-$wmfMasterServices = $wmfAllServices['eqiad'];
diff --git a/wmf-config/ProductionServices.php 
b/wmf-config/ProductionServices.php
index fb7a32a..e32d91d 100644
--- a/wmf-config/ProductionServices.php
+++ b/wmf-config/ProductionServices.php
@@ -23,6 +23,7 @@
        'eventbus' => 'http://eventbus.discovery.wmnet:8085',
        'upload' => 'upload.svc.eqiad.wmnet',
        'cxserver' => 'http://cxserver.discovery.wmnet:8080',
+       'etcd' => '_etcd._tcp.eqiad.wmnet',
 ];
 
 $wmfAllServices['codfw'] = [
@@ -37,6 +38,7 @@
        'eventbus' => 'http://eventbus.discovery.wmnet:8085',
        'upload' => 'upload.svc.codfw.wmnet',
        'cxserver' => 'http://cxserver.discovery.wmnet:8080',
+       'etcd' => '_etcd._tcp.codfw.wmnet',
 ];
 
 ### Logstash
@@ -138,9 +140,3 @@
        'rdb2003.codfw.wmnet:6378', // fallback
        'rdb2005.codfw.wmnet:6378', // fallback
 ];
-
-
-# Shorthand when we have no master-slave situation to keep into account
-$wmfLocalServices = $wmfAllServices[$wmfDatacenter];
-
-$wmfMasterServices = $wmfAllServices[$wmfMasterDatacenter];
diff --git a/wmf-config/etcd.php b/wmf-config/etcd.php
new file mode 100644
index 0000000..161be4e
--- /dev/null
+++ b/wmf-config/etcd.php
@@ -0,0 +1,44 @@
+<?php
+# WARNING: This file is publically viewable on the web. Do not put private 
data here.
+#
+# Included very early by CommonSettings.php
+# Only two sets of globals available here:
+# - $wmfRealm, $wmfDatacenter (from multiversion/MWRealm)
+# - $wmfLocalServices (from wmf-config/*Services.php)
+
+function wmfSetupEtcd() {
+       global $wmfRealm, $wmfDatacenter, $wmfLocalServices, $wgReadOnly, 
$wmfMasterDatacenter;
+
+       # Create a local cache
+       if ( PHP_SAPI === 'cli' ) {
+               $localCache = new HashBagOStuff;
+       } else {
+               $localCache = new APCBagOStuff;
+       }
+
+       # Set up local EtcdConfig with fallback to common EtcdConfig, this 
allows
+       # us to set $wgReadOnly differently in each datacenter
+       $etcdConfig = new MultiConfig( [
+               new EtcdConfig( [
+                       'host' => $wmfLocalServices['etcd'],
+                       'protocol' => 'https',
+                       'directory' => 
"conftool/v1/mediawiki-config/$wmfDatacenter",
+                       'cache' => $localCache,
+               ] ),
+               new EtcdConfig( [
+                       'host' => $wmfLocalServices['etcd'],
+                       'protocol' => 'https',
+                       'directory' => "conftool/v1/mediawiki-config/common",
+                       'cache' => $localCache,
+               ] ),
+       ] );
+
+       # Read only mode
+       $wgReadOnly = $etcdConfig->get( 'ReadOnly' );
+
+       # Master datacenter
+       # The datacenter from which we serve traffic.
+       $wmfMasterDatacenter = $etcdConfig->get( 'WMFMasterDatacenter' );
+}
+
+wmfSetupEtcd();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I23d4e7da0544e27bb3a4ad84f6f2ef195162fb2c
Gerrit-PatchSet: 14
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: Volans <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to