Giuseppe Lavagetto has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/351590 )
Change subject: Revert to using scap code deploys for MediaWiki
......................................................................
Revert to using scap code deploys for MediaWiki
Our tests with EtcdConfig showed it wasn't reliable enough.
This reverts commit ea76c8270cce74fe0076444391e4dd288fe4e4a7.
Change-Id: I42a9bd02dd036c489330deedebaca1dd227c7156
---
M switchdc/stages/t02_start_mediawiki_readonly.py
M switchdc/stages/t05_switch_datacenter.py
M switchdc/stages/t08_stop_mediawiki_readonly.py
3 files changed, 62 insertions(+), 22 deletions(-)
Approvals:
Giuseppe Lavagetto: Looks good to me, approved
jenkins-bot: Verified
Volans: Looks good to me, but someone else must approve
diff --git a/switchdc/stages/t02_start_mediawiki_readonly.py
b/switchdc/stages/t02_start_mediawiki_readonly.py
index 1e04240..900bddb 100644
--- a/switchdc/stages/t02_start_mediawiki_readonly.py
+++ b/switchdc/stages/t02_start_mediawiki_readonly.py
@@ -1,18 +1,36 @@
from datetime import datetime
+from switchdc import SwitchdcError
+from switchdc.dry_run import is_dry_run
from switchdc.lib import mediawiki
from switchdc.log import irc_logger, logger
-__title__ = 'Set MediaWiki in read-only mode in {dc_from}'
+__title__ = 'Set MediaWiki in read-only mode in {dc_from} (db-{dc_from} config
already merged and git pulled)'
def execute(dc_from, dc_to):
- """Set MediaWiki config readonly to True in dc_from and verify it."""
- message = 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes'
- mediawiki.set_readonly(message, dc=dc_from)
+ """Deploy the MediaWiki DB config for dc_from to set MediaWiki in
read-only mode.
- log_message = 'MediaWiki read-only period starts at:
{now}'.format(now=datetime.utcnow())
- logger.info(log_message)
- irc_logger.info(log_message)
+ Caution: the configuration must have already merged and git pullet in the
deployment host.
+ """
+ message = 'Set MediaWiki in read-only mode in datacenter
{dc_from}'.format(dc_from=dc_from)
+ filename = 'db-{dc_from}'.format(dc_from=dc_from)
+ expected = """'readOnlyBySection' => [
+\t's1' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+\t's2' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+\t'DEFAULT' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes', # s3
+\t's4' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+\t's5' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+\t's6' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+\t's7' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+],"""
- mediawiki.check_siteinfo('.query.general.readonly', attempts=5)
+ if not mediawiki.check_config_line(filename, expected):
+ log_message = 'MediaWiki read-only period starts at:
{now}'.format(now=datetime.utcnow())
+ logger.info(log_message)
+ irc_logger.info(log_message)
+ mediawiki.scap_sync_config_file(filename, message)
+ if not mediawiki.check_config_line(filename, expected) and not
is_dry_run():
+ logger.error('Read-only mode not changed in the MediaWiki config
{filename}?'.format(
+ filename=filename))
+ raise SwitchdcError(1)
diff --git a/switchdc/stages/t05_switch_datacenter.py
b/switchdc/stages/t05_switch_datacenter.py
index e863538..f159351 100644
--- a/switchdc/stages/t05_switch_datacenter.py
+++ b/switchdc/stages/t05_switch_datacenter.py
@@ -9,10 +9,10 @@
def execute(dc_from, dc_to):
- """Switchig the MediaWiki master DC in etcd for both DNS discovery and
MediaWiki config."""
+ """Switched the MediaWiki master DC in etcd and in the MediaWiki code."""
+ discovery = Confctl('discovery')
# 1: switch DNS discovery record for the new dc to on.
# This will NOT trigger confd to change the DNS admin state as it will
cause a validation error
- discovery = Confctl('discovery')
mw_records = '(appservers|api|imagescaler)-rw'
discovery.update({'pooled': True}, dnsdisc=mw_records, name=dc_to)
for obj in discovery.get(dnsdisc=mw_records, name=dc_to):
@@ -20,10 +20,15 @@
logger.error('DNS discovery record {record} is not
pooled'.format(record=obj.key))
raise SwitchdcError(1)
- # 2: Switch the MediaWiki config master DC
- mediawiki.set_master_datacenter(dc_to)
- mediawiki.check_siteinfo('.query.general["wmf-config"].wmfMasterDatacenter
== "{dc_to}"'.format(dc_to=dc_to),
- attempts=5)
+ # 2: Deploy the MediaWiki change already merged on the deployment server
in pre-flight phase
+ filename = 'CommonSettings'
+ message = 'Switch MediaWiki active datacenter to
{dc_to}'.format(dc_to=dc_to)
+ expected = "$wmfMasterDatacenter = '{dc_to}';".format(dc_to=dc_to)
+ if not mediawiki.check_config_line(filename, expected):
+ mediawiki.scap_sync_config_file(filename, message)
+ if not mediawiki.check_config_line(filename, expected) and not
is_dry_run():
+ logger.error('Datacenter not changed in the MediaWiki config?')
+ raise SwitchdcError(1)
# 3: switch off the old dc in conftool so that DNS discovery will be fixed
discovery.update({'pooled': False}, dnsdisc=mw_records, name=dc_from)
diff --git a/switchdc/stages/t08_stop_mediawiki_readonly.py
b/switchdc/stages/t08_stop_mediawiki_readonly.py
index 8d47f1b..f4575a5 100644
--- a/switchdc/stages/t08_stop_mediawiki_readonly.py
+++ b/switchdc/stages/t08_stop_mediawiki_readonly.py
@@ -1,19 +1,36 @@
from datetime import datetime
+from switchdc import SwitchdcError
+from switchdc.dry_run import is_dry_run
from switchdc.lib import mediawiki
from switchdc.log import irc_logger, logger
-__title__ = 'Set MediaWiki in read-write mode in {dc_to}'
+__title__ = 'Set MediaWiki in read-write mode in {dc_to} (db-{dc_to} config
already merged and git pulled)'
def execute(dc_from, dc_to):
- """Set MediaWiki config readonly to False in dc_to and verify it."""
- mediawiki.set_readonly(False, dc=dc_to)
+ """Deploy the MediaWiki DB config for dc_to to set MediaWiki in read-write
mode.
- mediawiki.check_siteinfo('.query.general.readonly | not', dc=dc_to,
attempts=5)
+ Caution: the configuration must have already merged and git pullet in the
deployment host.
+ """
+ message = 'Set MediaWiki in read-write mode in datacenter
{dc_to}'.format(dc_to=dc_to)
+ filename = 'db-{dc_to}'.format(dc_to=dc_to)
+ expected = """'readOnlyBySection' => [
+#\t's1' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+#\t's2' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+#\t'DEFAULT' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes', # s3
+#\t's4' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+#\t's5' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+#\t's6' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+#\t's7' => 'MediaWiki is in read-only mode for maintenance. Please try
again in a few minutes',
+],"""
- log_message = 'MediaWiki read-only period ends at:
{now}'.format(now=datetime.utcnow())
- logger.info(log_message)
- irc_logger.info(log_message)
+ if not mediawiki.check_config_line(filename, expected):
+ mediawiki.scap_sync_config_file(filename, message)
+ if not mediawiki.check_config_line(filename, expected) and not
is_dry_run():
+ logger.error('Read-only mode not changed in the MediaWiki config
{filename}?'.format(filename=filename))
+ raise SwitchdcError(1)
- mediawiki.check_siteinfo('.query.general.readonly', dc=dc_from, attempts=5)
+ log_message = 'MediaWiki read-only period ends at:
{now}'.format(now=datetime.utcnow())
+ logger.info(log_message)
+ irc_logger.info(log_message)
--
To view, visit https://gerrit.wikimedia.org/r/351590
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I42a9bd02dd036c489330deedebaca1dd227c7156
Gerrit-PatchSet: 2
Gerrit-Project: operations/switchdc
Gerrit-Branch: master
Gerrit-Owner: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[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