You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Switch Datacenter

From Wikitech-static
Revision as of 12:18, 9 October 2018 by imported>Ema (→‎Traffic: Update Inter-Cache routing CR link; don't say this step will happen in two days)
Jump to navigation Jump to search

Introduction

A datacenter switchover (from eqiad to codfw, or vice-versa) comprises switching over multiple different components, some of which can happen independently and many of which need to happen in lockstep. This page documents all the steps needed to switch over from a master datacenter to another one, broken up by component.

Schedule for 2018 switch

  • Services: Tuesday, September 11th 2018 14:30 UTC
  • Media storage/Swift: Tuesday, September 11th 2018 15:00 UTC
  • Traffic: Tuesday, September 11th 2018 19:00 UTC
  • MediaWiki: Wednesday, September 12th 2018: 14:00 UTC

Switching back:

  • Traffic: Wednesday, October 10th 2018 09:00 UTC
  • MediaWiki: Wednesday, October 10th 2018: 14:00 UTC
  • Services: Thursday, October 11th 2018 14:30 UTC
  • Media storage/Swift: Thursday, October 11th 2018 15:00 UTC

Per-service switchover instructions

MediaWiki

We divide the process in logical phases that should be executed sequentially. Within any phase, top-level tasks can be executed in parallel to each other, while subtasks are to be executed sequentially to each other. The phase number is referred to in the names of the tasks in the operations/cookbooks repository, in thecookbooks/sre/switchdc/mediawiki/ path.

Days in advance preparation

  1. OPTIONAL: SKIP IN AN EMERGENCY: Make sure databases are in a good state. Normally this requires no operation, as the passive datacenter databases are always prepared to receive traffic, so there are no actionables. Some things that #DBAs normally should make sure for the most optimal state possible (sanity checks):
    • There is no ongoing long-running maintenance that affects database availability or lag (schema changes, upgrades, hardware issues, etc.). Depool those servers that are not ready.
    • Replication is flowing from eqiad -> codfw and from codfw -> eqiad (sometimes replication gets stopped in the passive -> active direction to facilitate maintenance)
    • All database servers have its buffer pool filled up. This is taken care automatically with the automatic buffer pool warmup functionality. For sanity checks, some sample load could be sent to the mediawiki application server to check requests happen as quickly as in the active datacenter.
    • These where the things we prepared/checked for the 2018 switch
  2. Prepare puppet patches:

Phase 0 - preparation

  1. Disable puppet on maintenance hosts and cache::text in both eqiad and codfw: 00-disable-puppet.py
  2. Reduce the TTL on appservers-rw, api-rw, jobrunner, videoscaler to 10 seconds: 00-reduce-ttl.py For operational reasons to be able to run multiple steps one after the other, this step doesn't wait the old TTL (300s) to expire. Make sure that at least 5 minutes have passed before moving to Phase 1.
  3. Warm up APC running the mediawiki-cache-warmup on the new site clusters, specifically: 00-warmup-caches.py
    • The global warmup against the appservers cluster
    • The apc-warmup against all hosts in the appservers cluster.
  4. Set downtime for Read only checks on mariadb masters changed on Phase 3 (they will complain after the etcd primary master changes and until puppet runs there)

Phase 1 - stop maintenance and merge traffic changes

  1. Stop maintenance jobs in the active site and kill all the cronjobs on the maintenance host in the active site: 01-stop-maintenance.py
  2. Merge and puppet-merge the traffic change for text caches eqiad->codfw; codfw->eqiad. This is not covered by the switchdc script. Note: This does not yet switch traffic since puppet is disabled. Please use the following to SAL log !log Phase 1.2 - merge traffic switching puppet change.

Phase 2 - read-only mode

  1. Go to read-only mode by changing the ReadOnly conftool value: 02-set-readonly.py

Phase 3 - lock down database masters

  1. Put old-site core DB masters (shards: s1-s8, x1, es2-es3) in read-only mode and wait for the new site's databases to catch up replication: 03-set-db-readonly.py

Phase 4 - switch active datacenter configuration

  1. Send the traffic layer to active-active: 04-switch-traffic.py
    • enable and run puppet on cache::text in $new_site. This starts the active-active traffic phase (traffic will go to both MW clusters)
    • ensure that the change was applied on all hosts in $new_site
    • Run puppet on the text caches in $old_site. This ends the active-active phase.
  2. Switch the discovery records and MediaWiki active datacenter: 04-switch-mediawiki.py
    • Flip appservers-rw, api-rw, jobrunner, videoscaler to pooled=true in the new site. This will not actually change the DNS records for the active datacenter.
    • Flip WMFMasterDatacenter from the old site to the new.
    • Flip appservers-rw, api-rw, jobrunner, videoscaler to pooled=false in the old site. After this, DNS will be changed for the old DC and internal applications (but mediawiki!!) will start hitting the new DC

Phase 5 - Invert Redis replication for MediaWiki sessions

  1. Invert the Redis replication for the sessions cluster: 05-invert-redis-sessions.py

Phase 6 - Set new site's databases to read-write

  1. Set new-site's core DB masters (shards: s1-s8, x1, es2-es3) in read-write mode: 06-set-db-readwrite.py

Phase 7 - Set MediaWiki to read-write

  1. Go to read-write mode by changing the ReadOnly conftool value: 07-set-readwrite.py

Phase 8 - post read-only

  1. Start maintenance in the new DC: 08-start-maintenance.py
    1. Run puppet on the maintenance hosts
  2. Update tendril for new database masters: 08-update-tendril.py Pure cosmetic change, no effect on production. No changes required for database zarcillo (which has a different master for eqiad and codfw).
  3. Set the TTL for the DNS records to 300 seconds again: 08-restore-ttl.py
  4. Update DNS records for new database masters deploying eqiad->codfw; codfw->eqiad This is not covered by the switchdc script. Please use the following to SAL log !log Phase 8.4 Update DNS records for new database masters

Phase 9 - verification and troubleshooting

This is not covered by the switchdc script

  1. Make sure reading & editing works! :)
  2. Make sure recent changes are flowing (see Special:RecentChanges, EventStreams, and the IRC feeds)
  3. Make sure email works (exim4 -bp on mx1001/mx2001, test an email)

Dashboards

Media storage/Swift

Switchover

  • Set temporary active/active for Swift
  1. gerrit: C+2 and Submit commit https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/458794
  2. <any puppetmaster>: puppet-merge
  3. <any cumin master>: sudo cumin 'A:cp-upload_eqiad or A:cp-upload_codfw' 'run-puppet-agent'
  4. SAL log using !log Media storage/Swift Swift set to active/active
  • The above must complete correctly and fully (applying the change)
  • Set Swift to active/passive in codfw only:
  1. gerrit: C+2 and Submit commit https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/458795
  2. <any puppetmaster>: puppet-merge
  3. <any cumin master>: sudo cumin 'A:cp-upload_eqiad or A:cp-upload_codfw' 'run-puppet-agent'
  4. SAL log using !log Media storage/Swift Swift set to active/passive

Switching back

Repeat the steps above in reverse order with the commits https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/458796 and https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/458797 respectively

Dashboards

ElasticSearch

CirrusSearch talks by default to the local datacenter ($wmfDatacenter). If Mediawiki switches datacenter, elasticsearch will automatically follow.

Manually switching CirrusSearch to a specific datacenter can always be done. Point CirrusSearch to codfw by editing wmgCirrusSearchDefaultCluster InitialiseSettings.php.

To ensure coherence in case of lost updates, a reindex of the pages modified during the switch can be done by following Recovering from an Elasticsearch outage / interruption in updates.

Dashboards

Traffic

General information on generic procedures

https://wikitech.wikimedia.org/wiki/Global_Traffic_Routing

Switchover

Inter-Cache Routing:

  1. gerrit: C+2 and Submit commit https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/458808
  2. <any puppetmaster>: puppet-merge
  3. <any cumin master>: sudo cumin 'A:cp-esams' 'run-puppet-agent -q'

GeoDNS (User-facing) Routing:

  1. gerrit: C+2 and Submit commit https://gerrit.wikimedia.org/r/#/c/operations/dns/+/458806
  2. <any authdns node>: authdns-update

Switchback

Same procedures as above, with reversions of the commits specified. First reverting the inter-cache routing, then user routing. Respective changes: Inter-Cache Routing, GeoDNS.

Dashboards

Traffic - Services

For reference, the public-facing services involved which are confirmed active/active or failover-capable (other than MW and Swift, handled elsewhere):

  • cache_text:
    • restbase (active/passive for now)
    • eventstreams (active/active)
    • cxserver (active/active)
    • noc (active/active)
    • pybal_config (active/active)
    • wdqs (active/active)
    • ores (active/active)
  • cache_upload:
    • kartotherian (active/active) - aka maps

Switchover

  • Set temporary active/active for active/passive services above:
  1. gerrit: C+2 and Submit commit https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/458802
  2. <any frontend puppetmaster>: puppet-merge
  3. <any cumin master>: sudo cumin 'A:cp-text_eqiad or A:cp-text_codfw' 'run-puppet-agent'
  4. SAL Log using the following !log Traffic Inter-Cache routing switching
  • The above must complete correctly and fully (applying the change)
  • Set all active/active (including temps above) to active/passive in codfw only:
  1. gerrit: C+2 and Submit commit https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/458803
  2. <any frontend puppetmaster>: puppet-merge
  3. <any cumin master>: sudo cumin '(A:cp-text or A:cp-upload) and (A:eqiad or A:codfw)' 'run-puppet-agent'
  4. SAL Log using the following !log Traffic GeoDNS Routing switching

Switchback

Reverse the above with reverted commits, https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/458804 and https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/458805 respectively

Dashboards

Services

All services, are active-active in DNS discovery, apart from restbase, that needs special treatment. The procedure to fail over to one site only is the same for every one of them:

  1. reduce the TTL of the DNS discovery records to 10 seconds
  2. depool the datacenter we're moving away from in confctl / discovery
  3. restore the original TTL
  • All of the above is done using the sre.switchdc.services cookbooks

Restbase is a bit of a special case, and needs an additional step, if we're just switching active traffic over and not simulating a complete failover:

  1. pool restbase-async everywhere, then depool restbase-async in the newly active dc, so that async traffic is separated from real-users traffic as much as possible.

Other miscellaneous

Schedule of past switches

Schedule for 2017 switch

T138810 on Phabricator tracks tasks to be undertaken during the 2017 switch.

  • Elasticsearch: elasticsearch is automatically following mediawiki switch
  • Services: Tuesday, April 18th 2017 14:30 UTC
  • Media storage/Swift: Tuesday, April 18th 2017 15:00 UTC
  • Traffic: Tuesday, April 18th 2017 19:00 UTC
  • MediaWiki: Wednesday, April 19th 2017 14:00 UTC (user visible, requires read-only mode)
  • Deployment server: Wednesday, April 19th 2017 16:00 UTC

Switching back:

  • Traffic: Pre-switchback in two phases: Mon May 1 and Tue May 2 (to avoid cold-cache issues Weds)
  • MediaWiki: Wednesday, May 3rd 2017 14:00 UTC (user visible, requires read-only mode)
  • Elasticsearch: elasticsearch is automatically following mediawiki switch
  • Services: Thursday, May 4th 2017 14:30 UTC
  • Swift: Thursday, May 4th 2017 15:30 UTC
  • Deployment server: Thursday, May 4th 2017 16:00 UTC

Schedule for 2016 switch

  • Deployment server: Wednesday, January 20th 2016
  • Traffic: Thursday, March 10th 2016
  • MediaWiki 5-minute read-only test: Tuesday, March 15th 2016, 07:00 UTC
  • Elasticsearch: Thursday, April 7th 2016, 12:00 UTC
  • Media storage/Swift: Thursday, April 14th 2016, 17:00 UTC
  • Services: Monday, April 18th 2016, 10:00 UTC
  • MediaWiki: Tuesday, April 19th 2016, 14:00 UTC / 07:00 PDT / 16:00 CEST (requires read-only mode)

Switching back:

  • MediaWiki: Thursday, April 21st 2016, 14:00 UTC / 07:00 PDT / 16:00 CEST (requires read-only mode)
  • Services, Elasticsearch, Traffic, Swift, Deployment server: Thursday, April 21st 2016, after the above is done

Monitoring Dashboards

Aggregated list of interesting dashboards