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

Heterogeneous deployment/Train deploys: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
imported>Dduvall
(→‎Places to Watch for Breakage: Added link to Frontend Responses NGINX vs Varnish dashboard)
imported>Zfilipin
(→‎Clean up old stuff: 1.33 > 1.34)
Line 1: Line 1:
[[File:TGVA_n°341_au_PN_401_bis_à_La_Baule_par_Cramos.JPG|right|thumb|500px|Bring new code in fast, safe and efficient way!]]
[[File:广深港列車 2014-03-03 00-22.jpg|alt=|thumb|500x500px|Bring new code in a fast, safe and efficient way!]]
{{Navigation MediaWiki deployment}}
{{Navigation MediaWiki deployment}}
== Breakage ==
== Breakage ==
Line 12: Line 12:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging$ git revert $(git log -1 --format=%H -- wikiversions.json)
USERNAME@deploy1001:/srv/mediawiki-staging$ git revert $(git log -1 --format=%H -- wikiversions.json)
you@deploy1001:/srv/mediawiki-staging$ scap sync-wikiversions 'Revert "group[0|1] wikis to [VERSION]"'
USERNAME@deploy1001:/srv/mediawiki-staging$ scap sync-wikiversions 'Revert "group[0|1] wikis to [VERSION]"'
you@deploy1001:/srv/mediawiki-staging$ # Now that you've synced the revert, push patches up to gerrit, you have to run git commit --amend to get the changeid
USERNAME@deploy1001:/srv/mediawiki-staging$ # Now that you've synced the revert, push patches up to gerrit, you have to run git commit --amend to get the changeid
you@deploy1001:/srv/mediawiki-staging$ git commit --amend
USERNAME@deploy1001:/srv/mediawiki-staging$ git commit --amend
you@deploy1001:/srv/mediawiki-staging$ git push origin HEAD:refs/for/master/[VERSION]
USERNAME@deploy1001:/srv/mediawiki-staging$ git push origin HEAD:refs/for/master/[VERSION]
</syntaxhighlight>
</syntaxhighlight>


Line 22: Line 22:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging$ git push origin HEAD:refs/for/master/1.33.0-wmf.0
USERNAME@deploy1001:/srv/mediawiki-staging$ git push origin HEAD:refs/for/master/1.34.0-wmf.0
</syntaxhighlight>
</syntaxhighlight>


Line 39: Line 39:
* [https://logstash.wikimedia.org/app/kibana#/dashboard/Fatal-Monitor Logstash Fatal Monitor]
* [https://logstash.wikimedia.org/app/kibana#/dashboard/Fatal-Monitor Logstash Fatal Monitor]
* [https://logstash.wikimedia.org/app/kibana#/dashboard/mediawiki-errors Logstash MediaWiki Errors]
* [https://logstash.wikimedia.org/app/kibana#/dashboard/mediawiki-errors Logstash MediaWiki Errors]
**[https://logstash.wikimedia.org/app/kibana#/dashboard/a8ece250-1aaa-11e9-b4bc-db12fe15ab31 Excluding timeout errors] (see T204871)
**[https://logstash.wikimedia.org/app/kibana#/dashboard/dfcf7b70-1aaa-11e9-b4bc-db12fe15ab31 Showing only timeout errors] (see T204871)
* Group-specific Logstash Dashboards:
* Group-specific Logstash Dashboards:
** [https://logstash.wikimedia.org/app/kibana#/dashboard/group0 group0]
** [https://logstash.wikimedia.org/app/kibana#/dashboard/group0 group0]
Line 44: Line 46:
* [https://grafana.wikimedia.org/dashboard/db/varnish-http-errors?refresh=5m&orgId=1 Grafana Varnish error-rate dashboard] (HTTP 5XX % should have 3+ 0s after the decimal point, e.g. 0.0001%)
* [https://grafana.wikimedia.org/dashboard/db/varnish-http-errors?refresh=5m&orgId=1 Grafana Varnish error-rate dashboard] (HTTP 5XX % should have 3+ 0s after the decimal point, e.g. 0.0001%)
* [https://grafana.wikimedia.org/d/000000612/frontend-responses-nginx-vs-varnish?orgId=1&from=now-15m&to=now Grafana Frontend Responses NGINX vs Varnish]
* [https://grafana.wikimedia.org/d/000000612/frontend-responses-nginx-vs-varnish?orgId=1&from=now-15m&to=now Grafana Frontend Responses NGINX vs Varnish]
* [https://grafana.wikimedia.org/d/000000102/production-logging Grafana Production Logging]


=== If the train is blocked ===
=== If the train is blocked ===
Line 94: Line 97:
The script is run as your regular user member of the <code>wikidev</code> group (as of Feb 16th 2016).
The script is run as your regular user member of the <code>wikidev</code> group (as of Feb 16th 2016).


Configure Git.
Configure Git. You will need to ensure your <code>user.name</code> and <code>user.email</code> is set correctly. You will also need to ensure that you push to gerrit via <code>ssh</code> (as of Mar 18th, 2019).


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@laptop:~$ ssh deployment.eqiad.wmnet
USERNAME@MACIHNE-NAME:~$ ssh deployment.eqiad.wmnet


you@deploy1001:~$ git config --global user.name "[FIRST-NAME] [LAST-NAME]"
USERNAME@deploy1001:~$ git config --global user.name "[FIRST-NAME] [LAST-NAME]"
you@deploy1001:~$ git config --global user.email "[USERNAME]@[DOMAIN]"
USERNAME@deploy1001:~$ git config --global user.email "[USERNAME]@[DOMAIN]"
USERNAME@deploy1001:~$ git config --global url.ssh://[GERRIT-USERNAME]@gerrit.wikimedia.org:29418.pushInsteadOf https://gerrit.wikimedia.org/r
</syntaxhighlight>
</syntaxhighlight>


Create a <code>.netrc</code> file in your home directory with the following content.
Create a new ssh key to use from the deployment server.


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:~$ vim .netrc
USERNAME@deploy1001:~$ ssh-keygen -t ed25519
Enter file in which to save the key (/home/USERNAME/.ssh/id_ed25519): <enter>
Enter passphrase (empty for no passphrase): <passphrase>
Enter same passphrase again: <passphrase>
Your identification has been saved in /home/USERNAME/.ssh/id_ed25519.
Your public key has been saved in /home/USERNAME/.ssh/id_ed25519.pub.
</syntaxhighlight>
</syntaxhighlight>
Add your new <code>~/.ssh/id_ed25519.pub</code> key to Gerrit:
* In the new UI go to [https://gerrit.wikimedia.org/r/settings/#SSHKeys SSH keys], copy the contents of your <code>~/.ssh/id_ed25519.pub</code> file into the ui.
* In the old UI, go to [https://gerrit.wikimedia.org/r/settings/ssh-keys#SSHKeys SSH keys], copy the contents of your <code>~/.ssh/id_ed25519.pub</code> file into the ui.
Create a new ssh-agent so that your key remains unlocked during branch cutting:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
machine gerrit.wikimedia.org login [USERNAME] password [PASSWORD]
USERNAME@deploy1001:~$ eval $(ssh-agent)
USERNAME@deploy1001:~$ ssh-add ~/.ssh/id_ed25519
Enter passphrase for /home/USERNAME/.ssh/id_ed25519: <passphrase>
Identity added: /home/USERNAME/.ssh/id_ed25519 (USERNAME@deploy1001)
</syntaxhighlight>
</syntaxhighlight>


Username and password can obtained from Gerrit:
You should be able to list the keys in your agent and see your key there:
<syntaxhighlight lang="shell-session">
USERNAME@deploy1001:~$ ssh-add -l
256 SHA256:WSjdx+WFnlo9Dd+FN63c35+Q3pArOD/TQpFEjNh7ODc USERNAME@deploy1001 (ED25519)
</syntaxhighlight>


* In the new UI go to [https://gerrit.wikimedia.org/r/settings/#HTTPCredentials HTTP Credentials], copy <code>Username</code> and click <code>Generate new password</code> to generate new password.
Add Gerrit to <code>~/.ssh/known_hosts</code>. Fingerprint is available only in the old UI at [https://gerrit.wikimedia.org/r/#/settings/ssh-keys settings/ssh-keys].
* In the old UI, go to [https://gerrit.wikimedia.org/r/#/settings/http-password HTTP Password], copy <code>Username</code> and click <code>Generate Password</code> to generate new password.


Generated password in both cases is different from your Gerrit password.
<syntaxhighlight lang="shell-session">
USERNAME@deploy1001:~$ ssh -oFingerPrintHash=md5 -p 29418 GERRIT-USERNAME@gerrit.wikimedia.org
The authenticity of host '[gerrit.wikimedia.org]:29418 ([2620:0:861:3:208:80:154:85]:29418)' can't be established.
RSA key fingerprint is MD5:dc:e9:68:7b:99:1b:27:d0:f9:fd:ce:6a:2e:bf:92:e1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[gerrit.wikimedia.org]:29418,[2620:0:861:3:208:80:154:85]:29418' (RSA) to the list of known hosts.


Make sure <code>.netrc</code> file is only readable by you.
  ****    Welcome to Gerrit Code Review    ****


<syntaxhighlight lang="shell-session">
  Hi You, you have successfully connected over SSH.
you@deploy1001:~$ chmod go-rwx .netrc
 
  Unfortunately, interactive shells are disabled.
  To clone a hosted Git repository, use:
 
  git clone ssh://GERRIT-USERNAME@gerrit.wikimedia.org:29418/REPOSITORY_NAME.git
 
Connection to gerrit.wikimedia.org closed.
</syntaxhighlight>
</syntaxhighlight>


Line 129: Line 161:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:~$ git clone https://gerrit.wikimedia.org/r/mediawiki/tools/release
USERNAME@deploy1001:~$ git clone https://gerrit.wikimedia.org/r/mediawiki/tools/release
</syntaxhighlight>
</syntaxhighlight>


Line 139: Line 171:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:~$ tmux new -s train
USERNAME@deploy1001:~$ tmux new -s train
...
...
you@deploy1001:~$ exit
USERNAME@deploy1001:~$ exit
</syntaxhighlight>
</syntaxhighlight>


Line 149: Line 181:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:~$ screen -D -RR train
USERNAME@deploy1001:~$ screen -D -RR train
...
...
you@deploy1001:~$ exit
USERNAME@deploy1001:~$ exit
</syntaxhighlight>
</syntaxhighlight>


Line 159: Line 191:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:~/release/make-wmf-branch$ ./make-wmf-branch -n [VERSION] -o master
USERNAME@deploy1001:~/release/make-wmf-branch$ ./make-wmf-branch -n [VERSION] -o master
</syntaxhighlight>
</syntaxhighlight>


Line 165: Line 197:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:~/release/make-wmf-branch$ ./make-wmf-branch -n 1.33.0-wmf.0 -o master
USERNAME@deploy1001:~/release/make-wmf-branch$ ./make-wmf-branch -n 1.34.0-wmf.0 -o master
</syntaxhighlight>
</syntaxhighlight>


Line 174: Line 206:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging$ scap prep [VERSION]
USERNAME@deploy1001:/srv/mediawiki-staging$ scap prep [VERSION]
</syntaxhighlight>
</syntaxhighlight>


Line 180: Line 212:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging$ scap prep 1.33.0-wmf.0
USERNAME@deploy1001:/srv/mediawiki-staging$ scap prep 1.34.0-wmf.0
</syntaxhighlight>
</syntaxhighlight>


Line 190: Line 222:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:~$ tree /srv/patches/[VERSION]
USERNAME@deploy1001:~$ tree /srv/patches/[VERSION]
/srv/patches/[VERSION]
/srv/patches/[VERSION]
├── core
├── core
│   ├── 01-T[NUMBER].patch
│  ├── 01-T[NUMBER].patch
│   └── 02-T[NUMBER].patch
│  └── 02-T[NUMBER].patch
└── extensions
└── extensions
     └── [EXTENSION]
     └── [EXTENSION]
Line 202: Line 234:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/php-[VERSION]$ git apply --check --3way /srv/patches/[VERSION]/core/[NUMBER]-T[NUMBER].patch
USERNAME@deploy1001:/srv/mediawiki-staging/php-[VERSION]$ git apply --check --3way /srv/patches/[VERSION]/core/[NUMBER]-T[NUMBER].patch
</syntaxhighlight>
</syntaxhighlight>


Line 208: Line 240:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/php-[VERSION]$ git am --3way /srv/patches/[VERSION]/core/[NUMBER]-T[NUMBER].patch
USERNAME@deploy1001:/srv/mediawiki-staging/php-[VERSION]$ git am --3way /srv/patches/[VERSION]/core/[NUMBER]-T[NUMBER].patch
</syntaxhighlight>
</syntaxhighlight>


* If the patch fails to apply, investigate whether it's due to a conflict (<code>git status</code>) or the patch having been merged since the new branch cut (search <code>git log</code> for the commit, etc.). If it turns out to be the latter, remove the patch file from the <code>/srv/patches/[VERSION]</code> directory.
* If the patch fails to apply, investigate whether it's due to a conflict (<code>git status</code>) or the patch having been merged since the new branch cut (search <code>git log</code> for the commit, etc.). If it turns out to be the latter, remove the patch file from the <code>/srv/patches/[VERSION]</code> directory.
* If you need extra help, contact Security Team ([https://wikimediafoundation.org/wiki/Staff_and_contractors#Security Wikimedia Foundation], [https://www.mediawiki.org/wiki/Wikimedia_Security_Team MediaWiki], [https://office.wikimedia.org/wiki/Contact_list Office Wiki]), currently {{ircnick|bawolff|Brian}} and {{ircnick|Reedy|Sam}} in IRC.
* If you need extra help, contact Security Team ([https://wikimediafoundation.org/role/staff-contractors/ Wikimedia Foundation], [https://www.mediawiki.org/wiki/Wikimedia_Security_Team MediaWiki], [https://office.wikimedia.org/wiki/Contact_list#Security Office Wiki]), currently {{ircnick|bawolff|Brian}} and {{ircnick|Reedy|Sam}} in IRC.


==== Create patches to update wikiversions.json ====
==== Create patches to update wikiversions.json ====
Line 219: Line 251:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ scap update-wikiversions group0 [VERSION]
USERNAME@deploy1001:/srv/mediawiki-staging/$ scap update-wikiversions group0 [VERSION]
you@deploy1001:/srv/mediawiki-staging/$ git add wikiversions.json
USERNAME@deploy1001:/srv/mediawiki-staging/$ git add wikiversions.json
you@deploy1001:/srv/mediawiki-staging/$ git commit -m "Group0 to [VERSION]"
USERNAME@deploy1001:/srv/mediawiki-staging/$ git commit -m "Group0 to [VERSION]"
</syntaxhighlight>
</syntaxhighlight>


Line 227: Line 259:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ scap update-wikiversions group0 1.33.0-wmf.0
USERNAME@deploy1001:/srv/mediawiki-staging/$ scap update-wikiversions group0 1.34.0-wmf.0
you@deploy1001:/srv/mediawiki-staging/$ git add wikiversions.json
USERNAME@deploy1001:/srv/mediawiki-staging/$ git add wikiversions.json
you@deploy1001:/srv/mediawiki-staging/$ git commit -m "Group0 to 1.33.0-wmf.0"
USERNAME@deploy1001:/srv/mediawiki-staging/$ git commit -m "Group0 to 1.34.0-wmf.0"
</syntaxhighlight>
</syntaxhighlight>


Line 235: Line 267:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ git push origin HEAD:refs/for/master/[VERSION]
USERNAME@deploy1001:/srv/mediawiki-staging/$ git push origin HEAD:refs/for/master/[VERSION]
</syntaxhighlight>
</syntaxhighlight>


Line 241: Line 273:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ git push origin HEAD:refs/for/master/1.33.0-wmf.0
USERNAME@deploy1001:/srv/mediawiki-staging/$ git push origin HEAD:refs/for/master/1.34.0-wmf.0
</syntaxhighlight>
</syntaxhighlight>


Line 247: Line 279:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ git reset --hard origin/master
USERNAME@deploy1001:/srv/mediawiki-staging/$ git reset --hard origin/master
</syntaxhighlight>
</syntaxhighlight>


==== Clean up old stuff ====
==== Clean up old stuff ====


[[:mw:MediaWiki 1.33/Roadmap]] is a good place to find when a branch was created.
[[:mw:MediaWiki 1.34/Roadmap]] is a good place to find when a branch was created.


List all branches:
List all branches:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ find . -maxdepth 1 -type d -name 'php-*' -print
USERNAME@deploy1001:/srv/mediawiki-staging/$ find . -maxdepth 1 -type d -name 'php-*' -print
</syntaxhighlight>
</syntaxhighlight>


Line 263: Line 295:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ find . -mindepth 2 -maxdepth 2 -type f -path './php-*/README' -ctime +30 -exec dirname {} \;
USERNAME@deploy1001:/srv/mediawiki-staging/$ find . -mindepth 2 -maxdepth 2 -type f -path './php-*/README' -ctime +30 -exec dirname {} \;
</syntaxhighlight>
</syntaxhighlight>


Line 269: Line 301:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ scap clean --delete [VERSION]
USERNAME@deploy1001:/srv/mediawiki-staging/$ scap clean --delete [VERSION]
</syntaxhighlight>
</syntaxhighlight>


Line 275: Line 307:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ scap clean --delete 1.33.0-wmf.0
USERNAME@deploy1001:/srv/mediawiki-staging/$ scap clean --delete 1.34.0-wmf.0
</syntaxhighlight>
</syntaxhighlight>


Line 281: Line 313:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ scap clean [VERSION]
USERNAME@deploy1001:/srv/mediawiki-staging/$ scap clean [VERSION]
</syntaxhighlight>
</syntaxhighlight>


Line 287: Line 319:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ scap clean 1.33.0-wmf.0
USERNAME@deploy1001:/srv/mediawiki-staging/$ scap clean 1.34.0-wmf.0
</syntaxhighlight>
</syntaxhighlight>


Line 295: Line 327:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ vim wikiversions.json
USERNAME@deploy1001:/srv/mediawiki-staging/$ vim wikiversions.json
</syntaxhighlight>
</syntaxhighlight>


Line 302: Line 334:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ scap sync "testwiki to php-[VERSION] and rebuild l10n cache"
USERNAME@deploy1001:/srv/mediawiki-staging/$ scap sync "testwiki to php-[VERSION] and rebuild l10n cache"
</syntaxhighlight>
</syntaxhighlight>


Line 308: Line 340:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ scap sync "testwiki to php-1.33.0-wmf.0 and rebuild l10n cache"
USERNAME@deploy1001:/srv/mediawiki-staging/$ scap sync "testwiki to php-1.34.0-wmf.0 and rebuild l10n cache"
</syntaxhighlight>
</syntaxhighlight>


Line 316: Line 348:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging/$ git checkout -- wikiversions.json
USERNAME@deploy1001:/srv/mediawiki-staging/$ git checkout -- wikiversions.json
</syntaxhighlight>
</syntaxhighlight>


==== Update deploy notes ====
==== Update deploy notes ====


* Create deploy notes
* Deploy notes are automatically generated by the [https://integration.wikimedia.org/ci/job/train-deploy-notes Train Deploy Notes] Jenkins job after you cut the branch
 
* Be sure to check that the appropriate Changelog was created at <code><nowiki>https://www.mediawiki.org/wiki/MediaWiki_[VERSION]/Changelog</nowiki></code>. Example: [https://www.mediawiki.org/wiki/MediaWiki_1.34/wmf.4/Changelog MediaWiki 1.34/wmf.4/Changelog]
<syntaxhighlight lang="shell-session">
you@deploy1001:~$ ./release/make-deploy-notes/makedeploynotes.py [PREVIOUS-VERSION] [VERSION] | tee deploy-notes-[VERSION]
</syntaxhighlight>
 
Example:
 
<syntaxhighlight lang="shell-session">
you@deploy1001:~$ ./release/make-deploy-notes/makedeploynotes.py 1.33.0-wmf.0 1.33.0-wmf.1 | tee deploy-notes-1.33.0-wmf.1
</syntaxhighlight>
 
* Copy and paste from that file to <code><nowiki>https://www.mediawiki.org/wiki/MediaWiki_1.[NUMBER]/wmf.[NUMBER]/Changelog</nowiki></code> (Example: https://www.mediawiki.org/wiki/MediaWiki_1.33/wmf.1/Changelog)


==== Wait for deploy window ====
==== Wait for deploy window ====
Line 346: Line 367:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging$ git fetch
USERNAME@deploy1001:/srv/mediawiki-staging$ git fetch
</syntaxhighlight>
</syntaxhighlight>


Line 352: Line 373:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging$ git diff HEAD..origin/master
USERNAME@deploy1001:/srv/mediawiki-staging$ git diff HEAD..origin/master
</syntaxhighlight>
</syntaxhighlight>


Line 358: Line 379:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging$ git rebase origin/master
USERNAME@deploy1001:/srv/mediawiki-staging$ git rebase origin/master
</syntaxhighlight>
</syntaxhighlight>


Line 364: Line 385:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging$ scap sync-wikiversions "group0 to [VERSION]"
USERNAME@deploy1001:/srv/mediawiki-staging$ scap sync-wikiversions "group0 to [VERSION]"
</syntaxhighlight>
</syntaxhighlight>


Line 370: Line 391:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:/srv/mediawiki-staging$ scap sync-wikiversions "group0 to 1.33.0-wmf.0"
USERNAME@deploy1001:/srv/mediawiki-staging$ scap sync-wikiversions "group0 to 1.34.0-wmf.0"
</syntaxhighlight>
</syntaxhighlight>


Line 377: Line 398:


==== Update roadmap ====
==== Update roadmap ====
* Change the <code>Deployed to group</code> (if you're using VisualEditor) or the 3rd parameter of the <code>WMFReleaseTableRow</code> template (if you're using the wikitext editor) to <code>0</code> (deployed to group0) at [[:mw:MediaWiki 1.33/Roadmap]].
* Change the <code>Deployed to group</code> (if you're using VisualEditor) or the 3rd parameter of the <code>WMFReleaseTableRow</code> template (if you're using the wikitext editor) to <code>0</code> (deployed to group0) at [[:mw:MediaWiki 1.34/Roadmap]].


For wikitext editor, change
For wikitext editor, change
Line 413: Line 434:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:~$ ./release/bin/deploy-promote
USERNAME@deploy1001:~$ ./release/bin/deploy-promote
Promote group1 from [PREVIOUS-VERSION] to [VERSION] [y/N]
Promote group1 from [PREVIOUS-VERSION] to [VERSION] [y/N]
</syntaxhighlight>
</syntaxhighlight>


The script automatically Code-Review +2 the patch in Gerrit. Once CI has merged it hit enter at the 2nd prompt
The script automatically Code-Review +2 the patch in Gerrit. Once CI has merged the patch, hit enter at the 2nd prompt.


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
Line 426: Line 447:


==== Update roadmap ====
==== Update roadmap ====
* Change the <code>Deployed to group</code> (if you're using VisualEditor) or the 3rd parameter of the <code>WMFReleaseTableRow</code> template (if you're using the wikitext editor) to <code>1</code> (deployed to group1) at [[:mw:MediaWiki 1.33/Roadmap]].
* Change the <code>Deployed to group</code> (if you're using VisualEditor) or the 3rd parameter of the <code>WMFReleaseTableRow</code> template (if you're using the wikitext editor) to <code>1</code> (deployed to group1) at [[:mw:MediaWiki 1.34/Roadmap]].


For wikitext editor, change
For wikitext editor, change
Line 455: Line 476:


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
you@deploy1001:~$ ./release/bin/deploy-promote all
USERNAME@deploy1001:~$ ./release/bin/deploy-promote all
Promote all from [PREVIOUS-VERSION] to [VERSION] [y/N]
Promote all from [PREVIOUS-VERSION] to [VERSION] [y/N]
</syntaxhighlight>
</syntaxhighlight>


The script automatically Code-Review +2 the patch in Gerrit. Once CI has merged it hit enter at the 2nd prompt
The script automatically Code-Review +2 the patch in Gerrit. Once CI has merged the patch, hit enter at the 2nd prompt.


<syntaxhighlight lang="shell-session">
<syntaxhighlight lang="shell-session">
Line 468: Line 489:


==== Update roadmap ====
==== Update roadmap ====
* Change the <code>Deployed to group</code> (if you're using VisualEditor) or the 3rd parameter of the <code>WMFReleaseTableRow</code> template (if you're using the wikitext editor) to <code>2</code> (deployed to all wikis) at [[:mw:MediaWiki 1.33/Roadmap]].
* Change the <code>Deployed to group</code> (if you're using VisualEditor) or the 3rd parameter of the <code>WMFReleaseTableRow</code> template (if you're using the wikitext editor) to <code>2</code> (deployed to all wikis) at [[:mw:MediaWiki 1.34/Roadmap]].


For wikitext editor, change
For wikitext editor, change

Revision as of 10:36, 28 May 2019

Bring new code in a fast, safe and efficient way!
Deployments

Breakage

There will be times when this process does not go smoothly. There are guidelines for what do to when that happens.

In general, if there is an unexplained error that occurs within 1 hour of a train deployment — always roll back the train. Rolling back the train to eliminate it as the cause of unexplained breakage can be especially important if there are many ongoing possible causes for issues as this helps to eliminate one of those causes as the source of problems.

Rollback

To rollback a wikiversion change, it should be pretty quick. Go ahead and rollback production before you send patches up to gerrit since waiting on Jenkins may take a while:

USERNAME@deploy1001:/srv/mediawiki-staging$ git revert $(git log -1 --format=%H -- wikiversions.json)
USERNAME@deploy1001:/srv/mediawiki-staging$ scap sync-wikiversions 'Revert "group[0|1] wikis to [VERSION]"'
USERNAME@deploy1001:/srv/mediawiki-staging$ # Now that you've synced the revert, push patches up to gerrit, you have to run git commit --amend to get the changeid
USERNAME@deploy1001:/srv/mediawiki-staging$ git commit --amend
USERNAME@deploy1001:/srv/mediawiki-staging$ git push origin HEAD:refs/for/master/[VERSION]

Example:

USERNAME@deploy1001:/srv/mediawiki-staging$ git push origin HEAD:refs/for/master/1.34.0-wmf.0
  • Review and +2 the patch in Gerrit.

Places to Watch for Breakage

Train deployers should check for breakage as they are rolling out train as they are effectively the first line of defense for train deploys. Some of the places to watch for breakage:

If the train is blocked

  • A task will be assigned to you, for example T191059 (1.32.0-wmf.13 deployment blockers)
  • Any open subtasks block the train from moving forward. This means no further deployments until the blockers are resolved.

Checklist

If there are blocking tasks, please do the following:

  • Make sure all tasks blocking train are set to UBN! priority in phabricator
  • Comment on the task asking for an ETA or if this can be solved by reverting a recent commit.
  • Send e-mail to:
    • engineering@lists.wikimedia.org
    • ops@lists.wikimedia.org
    • wikitech-ambassadors@lists.wikimedia.org
    • wikitech-l@lists.wikimedia.org
    • Subject: [Train] {version} status update
    • Body
      The {version} version of MediaWiki is blocked[0].
      
      The new version is deployed to {group(s){0,1,2}}[1], but can proceed no
      further until these issues are resolved:
      
      * {Phab task name} - {phab task link}
      
      Once these issues are resolved train can resume. If these issues are
      resolved on a Friday the train will resume Monday.
      
      Thank you for your help resolving these issues!
      
      -- Your humble train toiler
      
      [0]. <{link to phab task for train}>
      [1]. <https://tools.wmflabs.org/versions/>
      
  • Add relevant people (see Developers/Maintainers) to the blocking task
  • Ping relevant people in IRC
  • Once train is unblocked be sure to thank the folks who helped unblock it

Tuesday: New branch creation and deploy

The new branch can be created in Gerrit from anywhere. It is often faster to do this step on a host in the cluster to minimize the time needed to clone from Gerrit.

Before the deploy window

Depending on how practiced you are and where you choose to run commands (full clones of mediawiki-core from outside the cluster can take a while) the steps will typically take 45 to 90 minutes.

Setup

The script is run as your regular user member of the wikidev group (as of Feb 16th 2016).

Configure Git. You will need to ensure your user.name and user.email is set correctly. You will also need to ensure that you push to gerrit via ssh (as of Mar 18th, 2019).

USERNAME@MACIHNE-NAME:~$ ssh deployment.eqiad.wmnet

USERNAME@deploy1001:~$ git config --global user.name "[FIRST-NAME] [LAST-NAME]"
USERNAME@deploy1001:~$ git config --global user.email "[USERNAME]@[DOMAIN]"
USERNAME@deploy1001:~$ git config --global url.ssh://[GERRIT-USERNAME]@gerrit.wikimedia.org:29418.pushInsteadOf https://gerrit.wikimedia.org/r

Create a new ssh key to use from the deployment server.

USERNAME@deploy1001:~$ ssh-keygen -t ed25519
Enter file in which to save the key (/home/USERNAME/.ssh/id_ed25519): <enter>
Enter passphrase (empty for no passphrase): <passphrase>
Enter same passphrase again: <passphrase>
Your identification has been saved in /home/USERNAME/.ssh/id_ed25519.
Your public key has been saved in /home/USERNAME/.ssh/id_ed25519.pub.

Add your new ~/.ssh/id_ed25519.pub key to Gerrit:

  • In the new UI go to SSH keys, copy the contents of your ~/.ssh/id_ed25519.pub file into the ui.
  • In the old UI, go to SSH keys, copy the contents of your ~/.ssh/id_ed25519.pub file into the ui.

Create a new ssh-agent so that your key remains unlocked during branch cutting:

USERNAME@deploy1001:~$ eval $(ssh-agent)
USERNAME@deploy1001:~$ ssh-add ~/.ssh/id_ed25519
Enter passphrase for /home/USERNAME/.ssh/id_ed25519: <passphrase>
Identity added: /home/USERNAME/.ssh/id_ed25519 (USERNAME@deploy1001)

You should be able to list the keys in your agent and see your key there:

USERNAME@deploy1001:~$ ssh-add -l
256 SHA256:WSjdx+WFnlo9Dd+FN63c35+Q3pArOD/TQpFEjNh7ODc USERNAME@deploy1001 (ED25519)

Add Gerrit to ~/.ssh/known_hosts. Fingerprint is available only in the old UI at settings/ssh-keys.

USERNAME@deploy1001:~$ ssh -oFingerPrintHash=md5 -p 29418 GERRIT-USERNAME@gerrit.wikimedia.org
The authenticity of host '[gerrit.wikimedia.org]:29418 ([2620:0:861:3:208:80:154:85]:29418)' can't be established.
RSA key fingerprint is MD5:dc:e9:68:7b:99:1b:27:d0:f9:fd:ce:6a:2e:bf:92:e1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[gerrit.wikimedia.org]:29418,[2620:0:861:3:208:80:154:85]:29418' (RSA) to the list of known hosts.

  ****    Welcome to Gerrit Code Review    ****

  Hi You, you have successfully connected over SSH.

  Unfortunately, interactive shells are disabled.
  To clone a hosted Git repository, use:

  git clone ssh://GERRIT-USERNAME@gerrit.wikimedia.org:29418/REPOSITORY_NAME.git

Connection to gerrit.wikimedia.org closed.

Clone or update mediawiki/tools/release.

USERNAME@deploy1001:~$ git clone https://gerrit.wikimedia.org/r/mediawiki/tools/release

tmux or screen

Some scripts run for 10-60 minutes so consider using tmux or screen.

If you prefer tmux:

USERNAME@deploy1001:~$ tmux new -s train
...
USERNAME@deploy1001:~$ exit

If you need to leave in the middle you can do ctrl-b d to detach and tmux a -t train to attach.

If you prefer screen:

USERNAME@deploy1001:~$ screen -D -RR train
...
USERNAME@deploy1001:~$ exit

If you need to leave in the middle you can do ctrl-a d to detach and screen -r train to attach.

Create the new branch in Gerrit

USERNAME@deploy1001:~/release/make-wmf-branch$ ./make-wmf-branch -n [VERSION] -o master

Example:

USERNAME@deploy1001:~/release/make-wmf-branch$ ./make-wmf-branch -n 1.34.0-wmf.0 -o master

🐌 Note: the script will run for about 15 minutes.

Clone new branch

This command will create a new /srv/mediawiki-staging/php-[VERSION] directory:

USERNAME@deploy1001:/srv/mediawiki-staging$ scap prep [VERSION]

Example:

USERNAME@deploy1001:/srv/mediawiki-staging$ scap prep 1.34.0-wmf.0

Apply security patches

  • Patches should be named sequentially in the order that they will cleanly apply (e.g. 01-T[NUMBER].patch, 02-T[NUMBER].patch)
  • Check and apply each patch in both /srv/patches/[VERSION]/core and /srv/patches/[VERSION]/extensions/[NAME] to the new core checkout and extensions, respectively.

Check existing patches:

USERNAME@deploy1001:~$ tree /srv/patches/[VERSION]
/srv/patches/[VERSION]
├── core
│   ├── 01-T[NUMBER].patch
│   └── 02-T[NUMBER].patch
└── extensions
    └── [EXTENSION]
  • You can check a core patch to see if it will apply cleanly with
USERNAME@deploy1001:/srv/mediawiki-staging/php-[VERSION]$ git apply --check --3way /srv/patches/[VERSION]/core/[NUMBER]-T[NUMBER].patch
  • If the patch checks out, apply and commit it with
USERNAME@deploy1001:/srv/mediawiki-staging/php-[VERSION]$ git am --3way /srv/patches/[VERSION]/core/[NUMBER]-T[NUMBER].patch
  • If the patch fails to apply, investigate whether it's due to a conflict (git status) or the patch having been merged since the new branch cut (search git log for the commit, etc.). If it turns out to be the latter, remove the patch file from the /srv/patches/[VERSION] directory.
  • If you need extra help, contact Security Team (Wikimedia Foundation, MediaWiki, Office Wiki), currently Brian (bawolff) and Sam (Reedy) in IRC.

Create patches to update wikiversions.json

Create group0 to [VERSION] patch:

USERNAME@deploy1001:/srv/mediawiki-staging/$ scap update-wikiversions group0 [VERSION]
USERNAME@deploy1001:/srv/mediawiki-staging/$ git add wikiversions.json
USERNAME@deploy1001:/srv/mediawiki-staging/$ git commit -m "Group0 to [VERSION]"

Example:

USERNAME@deploy1001:/srv/mediawiki-staging/$ scap update-wikiversions group0 1.34.0-wmf.0
USERNAME@deploy1001:/srv/mediawiki-staging/$ git add wikiversions.json
USERNAME@deploy1001:/srv/mediawiki-staging/$ git commit -m "Group0 to 1.34.0-wmf.0"

Send staged patches to Gerrit for review

USERNAME@deploy1001:/srv/mediawiki-staging/$ git push origin HEAD:refs/for/master/[VERSION]

Example:

USERNAME@deploy1001:/srv/mediawiki-staging/$ git push origin HEAD:refs/for/master/1.34.0-wmf.0

Discard changes to working directory and index

USERNAME@deploy1001:/srv/mediawiki-staging/$ git reset --hard origin/master

Clean up old stuff

mw:MediaWiki 1.34/Roadmap is a good place to find when a branch was created.

List all branches:

USERNAME@deploy1001:/srv/mediawiki-staging/$ find . -maxdepth 1 -type d -name 'php-*' -print

Find old branches, more than 30 days old:

USERNAME@deploy1001:/srv/mediawiki-staging/$ find . -mindepth 2 -maxdepth 2 -type f -path './php-*/README' -ctime +30 -exec dirname {} \;

For all branches more than 30 days old, drop everything.

USERNAME@deploy1001:/srv/mediawiki-staging/$ scap clean --delete [VERSION]

Example:

USERNAME@deploy1001:/srv/mediawiki-staging/$ scap clean --delete 1.34.0-wmf.0

For all branches older than the currently active branch(es) and prior one, prune everything that's not a static asset (we need those for cached CSS/JS/etc). Active branches are visible at Wikimedia MediaWiki versions page.

USERNAME@deploy1001:/srv/mediawiki-staging/$ scap clean [VERSION]

Example:

USERNAME@deploy1001:/srv/mediawiki-staging/$ scap clean 1.34.0-wmf.0

Sync to cluster and verify on testwiki

  • Edit /srv/mediawiki-staging/wikiversions.json and set testwiki to php-[VERSION]
  • Do not commit and push to Gerrit, only make this change locally on the deployment server
USERNAME@deploy1001:/srv/mediawiki-staging/$ vim wikiversions.json
  • Run scap to (re)build localization caches and sync changes across the cluster.
  • 🐌 Note: this step will for about 20 minutes.
USERNAME@deploy1001:/srv/mediawiki-staging/$ scap sync "testwiki to php-[VERSION] and rebuild l10n cache"

Example:

USERNAME@deploy1001:/srv/mediawiki-staging/$ scap sync "testwiki to php-1.34.0-wmf.0 and rebuild l10n cache"
  • Revert local changes
USERNAME@deploy1001:/srv/mediawiki-staging/$ git checkout -- wikiversions.json

Update deploy notes

  • Deploy notes are automatically generated by the Train Deploy Notes Jenkins job after you cut the branch
  • Be sure to check that the appropriate Changelog was created at https://www.mediawiki.org/wiki/MediaWiki_[VERSION]/Changelog. Example: MediaWiki 1.34/wmf.4/Changelog

Wait for deploy window

All of the changes above can be done at any time prior to the actual deployment window.

During the deploy window

Switch group0 wikis to [VERSION]

  • Review and submit group0 to [VERSION] patch in Gerrit
  • Wait for Gerrit/Zuul/Jenkins to merge the patch(es)
  • Pull patch(es) to deployment server
USERNAME@deploy1001:/srv/mediawiki-staging$ git fetch
  • Check diff to ensure it is what you expect
USERNAME@deploy1001:/srv/mediawiki-staging$ git diff HEAD..origin/master
  • Apply changes
USERNAME@deploy1001:/srv/mediawiki-staging$ git rebase origin/master
  • Sync the change across the cluster
USERNAME@deploy1001:/srv/mediawiki-staging$ scap sync-wikiversions "group0 to [VERSION]"

Example:

USERNAME@deploy1001:/srv/mediawiki-staging$ scap sync-wikiversions "group0 to 1.34.0-wmf.0"

Update roadmap

  • Change the Deployed to group (if you're using VisualEditor) or the 3rd parameter of the WMFReleaseTableRow template (if you're using the wikitext editor) to 0 (deployed to group0) at mw:MediaWiki 1.34/Roadmap.

For wikitext editor, change

{{WMFReleaseTableHead}}
{{WMFReleaseTableRow|[VERSION]|[DATE]|}}
...
{{WMFReleaseTableFooter}}

to

{{WMFReleaseTableHead}}
{{WMFReleaseTableRow|[VERSION]|[DATE]|0}}
...
{{WMFReleaseTableFooter}}

Example:

{{WMFReleaseTableHead}}
{{WMFReleaseTableRow|12|2018-07-10|0}}
...
{{WMFReleaseTableFooter}}

Wednesday: group0 to group1 deploy

Switch group1 wikis to [VERSION]

Use the release/bin/deploy-promote script to update wikiversions.json

USERNAME@deploy1001:~$ ./release/bin/deploy-promote
Promote group1 from [PREVIOUS-VERSION] to [VERSION] [y/N]

The script automatically Code-Review +2 the patch in Gerrit. Once CI has merged the patch, hit enter at the 2nd prompt.

Now wait for jenkins to merge the patch, then press enter to continue with git pull && scap sync-wikiversions

After the script run is complete, group1 wikis should be running [VERSION].

Update roadmap

  • Change the Deployed to group (if you're using VisualEditor) or the 3rd parameter of the WMFReleaseTableRow template (if you're using the wikitext editor) to 1 (deployed to group1) at mw:MediaWiki 1.34/Roadmap.

For wikitext editor, change

{{WMFReleaseTableRow|[VERSION]|[DATE]|0}}

to

{{WMFReleaseTableRow|[VERSION]|[DATE]|1}}

Example:

{{WMFReleaseTableRow|12|2018-07-10|1}}

Thursday: group{0,1} to all deploy

Switch all wikis to [VERSION]

Thursday deploy is very similar to the Wednesday deploy, the only difference in terms of procedure is the target group

Use the release/bin/deploy-promote all script to update wikiversions.json

USERNAME@deploy1001:~$ ./release/bin/deploy-promote all
Promote all from [PREVIOUS-VERSION] to [VERSION] [y/N]

The script automatically Code-Review +2 the patch in Gerrit. Once CI has merged the patch, hit enter at the 2nd prompt.

Now wait for jenkins to merge the patch, then press enter to continue with git pull && scap sync-wikiversions

After the script run is complete, all wikis should be running [VERSION].

Update roadmap

  • Change the Deployed to group (if you're using VisualEditor) or the 3rd parameter of the WMFReleaseTableRow template (if you're using the wikitext editor) to 2 (deployed to all wikis) at mw:MediaWiki 1.34/Roadmap.

For wikitext editor, change

{{WMFReleaseTableRow|[VERSION]|[DATE]|1}}

to

{{WMFReleaseTableRow|[VERSION]|[DATE]|2}}

Example:

{{WMFReleaseTableRow|12|2018-07-10|2}}

Incident documentation