Page MenuHomePhabricator

Migrate mw-script to PHP 8.1
Closed, ResolvedPublic

Description

Timeline:

  • Decouple mwscript-k8s MediaWiki image selection from mw-web.
  • Support PHP version selection in mwscript-k8s
  • Announce upcoming change to default to PHP 8.1 (2025-03-26)
  • Update https://wikitech.wikimedia.org/wiki/Maintenance_scripts to highlight the PHP default version change and fallback
  • Change default PHP version to 8.1 with fallback option to 7.4 (2025-04-02)

Implementation notes:

Currently, the mwscript-k8s tool determines which mediawiki image to use by simply following the one used by mw-web/main.

While that works, there's one caveat in the context of the 8.1 migration: If we take no action, when mw-web/main is converted to 8.1 in the near future, all mwscript-k8s use cases will implicitly be migrated as well. That's less than ideal.

I was chatting with @RLazarus the other day, and we discussed a more structured migration, where there will in the future be a (advertised) day where mwscript-k8s invocations switch to 8.1 by default, but with an escape hatch for users that experience issues with their scripts: a command-line flag to revert to a 7.4-based image. There would then be a later date when the flag is removed.

Achieving this would require decoupling the tool from mw-web/main. One idea for doing that would be to imbue scap with a notion of non-deploy helmfile releases - i.e., scap is only responsible for maintaining the files in /etc/helmfile-defaults/mediawiki/release, but does not attempt to "actuate" (e.g., helmfile apply) a deployment.

We could then configure 7.4- and 8.1- associated non-deploy releases in the mw-script namespace, whose release-values files would instead be consumed by the tool.

This could be broadly useful for other "asynchronous deployment" use cases that want to follow (by some other mechanism) the latest deployed images, and intersects a bit with some of the discussion in T375497 around when new image versions are "published" to /etc/helmfile-defaults/mediawiki/release.

Related Objects

StatusSubtypeAssignedTask
ResolvedNone
ResolvedReedy
StalledNone
OpenNone
OpenNone
OpenNone
ResolvedReedy
ResolvedKrinkle
ResolvedKrinkle
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
ResolvedLucas_Werkmeister_WMDE
ResolvedNone
ResolvedJdforrester-WMF
ResolvedDaimona
ResolvedJdforrester-WMF
DeclinedNone
ResolvedScott_French
ResolvedScott_French
ResolvedScott_French
Resolvedcscott
ResolvedScott_French
DuplicatePRODUCTION ERRORNone
ResolvedPRODUCTION ERRORMichael
ResolvedPRODUCTION ERRORMichael
ResolvedMichael
DuplicatePRODUCTION ERRORNone
ResolvedTgr
ResolvedNone
ResolvedDAlangi_WMF
ResolvedTgr
ResolvedDAlangi_WMF
ResolvedTgr
ResolvedTgr
ResolvedAtieno
OpenNone
Resolvedbrouberol
ResolvedScott_French
ResolvedScott_French
ResolvedScott_French
ResolvedScott_French
ResolvedScott_French
ResolvedScott_French
ResolvedKrinkle
ResolvedKrinkle
ResolvedScott_French
ResolvedKrinkle
ResolvedTgr
ResolvedScott_French
Resolvedjnuche
ResolvedJdforrester-WMF
ResolvedBUG REPORTbd808
ResolvedReedy
ResolvedReedy
Resolvedseanleong-WMDE
StalledNone
OpenNone
ResolvedLucas_Werkmeister_WMDE
ResolvedDaimona
ResolvedDaimona
ResolvedDaimona
OpenNone
ResolvedUmherirrender
OpenNone
ResolvedUmherirrender
ResolvedUmherirrender
Resolved mszabo
Resolvedtstarling
ResolvedUmherirrender
ResolvedDreamy_Jazz
ResolvedDreamy_Jazz
ResolvedPhysikerwelt
ResolvedTgr
ResolvedUmherirrender
ResolvedUmherirrender
ResolvedNone
ResolvedUmherirrender
ResolvedNone
ResolvedNone
ResolvedkarapayneWMDE
ResolvedAudreyPenven_WMDE
ResolvedAudreyPenven_WMDE
ResolvedLucas_Werkmeister_WMDE
ResolvedLucas_Werkmeister_WMDE
ResolvedUmherirrender
Resolvedthiemowmde
ResolvedLucas_Werkmeister_WMDE
ResolvedUmherirrender
ResolvedUmherirrender
ResolvedUmherirrender
ResolvedUmherirrender
ResolvedUmherirrender
ResolvedUmherirrender
Resolved mszabo
ResolvedxSavitar
ResolvedUmherirrender
ResolvedUmherirrender
ResolvedUmherirrender
OpenNone
OpenNone
OpenNone
OpenDannyS712
ResolvedUmherirrender
Resolved larissagaulia
ResolvedUmherirrender
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
ResolvedJdforrester-WMF
ResolvedKrinkle
ResolvedScott_French
ResolvedScott_French

Event Timeline

This would be heplful for the staging deployments of mw-debug.

Change #1125473 had a related patch set uploaded (by Scott French; author: Scott French):

[operations/puppet@production] Profile::Mediawiki_deployment: add 'deploy' field to release config

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

Change #1125474 had a related patch set uploaded (by Scott French; author: Scott French):

[operations/puppet@production] hieradata: add mw-script non-deploy releases to mw_releases

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

Change #1125475 had a related patch set uploaded (by Scott French; author: Scott French):

[operations/puppet@production] deployment_server: Use mw-script release values file

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

Thanks, @Clement_Goubert - it's good to see that there's at least one other foreseeable concrete use case for this.

I've posted a MR for what one approach to this functionality might look like in scap (which I'm happy to revise) and a handful of puppet patches demonstrating what its use would look like (minus a patch for the "revert to 7.4" flag).

Scott_French changed the task status from Open to In Progress.Mar 10 2025, 8:50 PM
Scott_French triaged this task as Medium priority.

Many thanks to Ahmon, the scap changes to support non-deploy helmfile releases are live.

The three pending puppet patches to decouple from mw-web are ready to go, but I'll hold off on merging until tomorrow, out of an abundance of caution in the (unlikely) event the scap release is reverted.

Change #1125473 merged by Scott French:

[operations/puppet@production] Profile::Mediawiki_deployment: add 'deploy' field to release config

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

Change #1125474 merged by Scott French:

[operations/puppet@production] hieradata: add mw-script non-deploy releases to mw_releases

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

Mentioned in SAL (#wikimedia-operations) [2025-03-11T16:16:07Z] <swfrench@deploy2002> Started scap sync-world: No-op deploy to pick up mediawiki-deployments.yaml changes - T387917

Mentioned in SAL (#wikimedia-operations) [2025-03-11T16:18:16Z] <swfrench@deploy2002> Finished scap sync-world: No-op deploy to pick up mediawiki-deployments.yaml changes - T387917 (duration: 02m 42s)

Change #1125475 merged by Scott French:

[operations/puppet@production] deployment_server: Use mw-script release values file

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

Alright, I've run puppet-agent on the deployment host and verified mwscript-k8s works as expected following the switch in release values file.

Switching mw-web/main to PHP 8.1 is unblocked.

Next step: introduce the "default to 8.1, optional fallback to 7.4" functionality described in the task description.

Change #1126697 had a related patch set uploaded (by Scott French; author: Scott French):

[operations/puppet@production] deployment_server: Support PHP version selection in mwscript-k8s

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

Change #1126697 merged by Scott French:

[operations/puppet@production] deployment_server: Support PHP version selection in mwscript-k8s

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

Alright, I think the next step would be to announce the upcoming switch to default to PHP 8.1. This should provide a target date (TBD) and guidance on how to test scripts on 8.1 ahead of time (via --php_version 8.1).

@RLazarus - It would be good to get your thoughts here on: (1) an appropriate venue for the announcement (IIRC, you've sent mwscript-k8s related announcements to wikitech-l?) and (2) given uptake you've seen of the tool, how much lead time you'd recommend before the default switch.

Yes, I used wikitech-l to announce mwscript-k8s, and will use it again to announce when it becomes the only way. It's a good venue for this too.

You could also check to see who's run mwscript-k8s recently, and bcc them directly. Within the job cleanup TTL, that's easy:

kube_env mw-script eqiad; kubectl get job -ojson | jq '[.items[].metadata.labels.username] | unique'

but to go back further you'd need to ask Logstash. I think we have this in there somewhere for past jobs in both DCs, but I don't know offhand what query to pull it out with. This would be nice to do if it's easy; don't sweat it if it's inconvenient.

Also consider adding a message to the wrapper script itself, at the same time as you flip the default, to give a heads-up to anyone who didn't hear otherwise. (Suppress it if --mediawiki_image or --php_version is passed, and plan to remove it after the switch.) Doesn't need to be an interactive confirmation or anything, just a notification as an added troubleshooting hint if something unexpected happens.

In terms of lead time, I don't think you need much, especially since the escape hatch is right there. A week is probably plenty. (Most people who run one-off scripts do it on an erratic schedule, so it's hard to know what kind of interval to leave anyway.)

Change #1131351 had a related patch set uploaded (by Scott French; author: Scott French):

[operations/puppet@production] deployment_server: Default to PHP 8.1 in mwscript-k8s

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

Thanks, @RLazarus - that's really helpful. Also great idea adding a message to the script with instructions on how to revert back.

I'll draft something for wikitech-l and target a 1w timeline before the default switch. I need to give some thought to when we'll remove the ability to fall back to 7.4 ... I think it should suffice at the moment to explain that this will happen at some point (and have the tool emit a message indicating this when 7.4 is explicitly selected).

Alright, I've sent an announcement about the upcoming change to wikitech-l, explaining both the fallback option and the opportunity to test ahead of time (both via --php_version). We're targeting next Wednesday, 2nd of April, for the default change.

This is great! I have a few questions:

Will that be a standard moving forward every time we migrate to a new version? Is this work enough to create the desired structure when we upgrade to more versions in the future?

This is great! I have a few questions:

Will that be a standard moving forward every time we migrate to a new version? Is this work enough to create the desired structure when we upgrade to more versions in the future?

Yes, indeed - similar to the procedure we've laid out for migrating traffic-serving use cases, this should be readily reusable for future migrations once appropriately documented.

Change #1131351 merged by Scott French:

[operations/puppet@production] deployment_server: Default to PHP 8.1 in mwscript-k8s

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

Since there are no further actions explicitly tracked here, and indeed I've manually tested the new 8.1-default and 7.4-fallback, I'm going to close this out.

Removing the 7.4-fallback, which in turn unblocks no-longer building the 7.4 version of the MediaWiki app image, is tracked as part of T391057: Turn down MediaWiki image builds for PHP 7.4.