Page MenuHomePhabricator

Add helper script functionality to our php images
Closed, ResolvedPublic

Description

Currently, the periodic jobs rely on a few helper scripts:

Top-level wrapper

/usr/local/bin/mw-cli-wrapper
Responsible for checking the mediawiki read-only state and primary datacenter. To be updated to T367118: Control mw-on-k8s periodic maintenance jobs with an etcd value

General helper scripts

/usr/local/bin/foreachwiki # Wraps /usr/local/bin/foreachwikiindblist
/usr/local/bin/foreachwikiindblist # Wraps /usr/local/bin/expanddblist and calls php
/usr/local/bin/expanddblist
/usr/local/bin/mwscriptwikiset # Wraps /usr/local/bin/mwscript
/usr/local/bin/mwscript # Calls php

These scripts all end up wrapping a php cli invocation using environment variables from /etc/profile.d/mediawiki.sh. These environment variables can be set in the Job Spec.

Ad-hoc scripts for a specific periodic job

/usr/local/bin/captchaloop # Wraps /usr/local/bin/mwscript
/usr/local/bin/characterEditStatsTranslate # Wraps /usr/local/bin/mwscript
/usr/local/bin/cirrus_build_completion_indices.sh # Wraps /usr/local/bin/expanddblist

Integration into the k8s CronJob world

For the general helper scripts (including /usr/local/bin/expanddblist), they should probably be included or injected in the container used to run the cronjobs rather than replicated using the container command in the jobTemplate.

There's a few options there, roughly listed from preferred to least preferred in my opinion:

  • Have a new mediawiki-multiversion-cli image that includes those helper scripts: Cleaner as far as separation of concerns goes, but adds one more image to maintain and build. Will need to install python for /usr/local/bin/mw-cli-wrapper
  • Use the production mediawiki-multiversion and inject the scripts as configmaps: Avoids building and maintaining a new image, while avoiding adding shell scripts to exposed containers. Feels kind of dirty as it's not configuration, but allows to just add the puppet definition for these scripts onto the deployment servers and for a faster feedback loop for their modification, as they would not need a new image to pick up the modifications.
  • Include the scripts in the mediawiki-multiversion-debug image: Avoids building and maintaining one more image, limits exposure to a couple of containers and can (maybe?) be useful to have the scripts for debugging. However, the pods are still exposed to outside traffic, raising security concerns.
  • Include the scripts in the production image: Adding shell scripts to all traffic-exposed containers is a security issue IMO, I'm only including it for completeness. Actually, it's not that big a deal, if these get run, we have more problems than these scripts being in the image.

Decision

Follow-up for special cases

Event Timeline

Change #1082478 had a related patch set uploaded (by Clément Goubert; author: Clément Goubert):

[operations/docker-images/production-images@master] php*-cli: Add helper scripts for mwcron, mwscript

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

Clement_Goubert changed the task status from Open to In Progress.Oct 23 2024, 2:43 PM

Change #1082478 merged by Clément Goubert:

[operations/docker-images/production-images@master] php*-fpm-multiversion: Add helper scripts for mwcron, mwscript

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

Mentioned in SAL (#wikimedia-operations) [2024-10-29T11:27:37Z] <claime> Rebuilding php{7.4,8.1}-fpm-multiversion-base - T377958

Mentioned in SAL (#wikimedia-operations) [2024-10-29T11:35:39Z] <cgoubert@deploy2002> Started scap sync-world: T377958 - full mediawiki image rebuild and deployment to add helper scripts for mwcron, mwscript

Mentioned in SAL (#wikimedia-operations) [2024-10-29T12:04:18Z] <cgoubert@deploy2002> Finished scap sync-world: T377958 - full mediawiki image rebuild and deployment to add helper scripts for mwcron, mwscript (duration: 29m 44s)

Helper scripts deployed and available in the mediawiki containers:

root@deploy2002:~# kubectl -n mw-debug exec mw-debug.eqiad.pinkunicorn-d67975fb5-kv2vs -c mediawiki-pinkunicorn-app -- mwscript Version.php testwiki
MediaWiki version: 1.44.0-wmf.1 (built: 23:47, 28 October 2024)
root@deploy2002:~# kubectl -n mw-debug exec mw-debug.eqiad.pinkunicorn-d67975fb5-kv2vs -c mediawiki-pinkunicorn-app -- foreachwikiindblist 'testwikis - wikitech' Version.php
testwiki:  MediaWiki version: 1.44.0-wmf.1 (built: 23:47, 28 October 2024)
testwikidatawiki:  MediaWiki version: 1.44.0-wmf.1 (built: 23:47, 28 October 2024)
root@deploy2002:~# kubectl -n mw-debug exec mw-debug.eqiad.pinkunicorn-d67975fb5-kv2vs -c mediawiki-pinkunicorn-app -- mwscriptwikiset 'testwikis - wiki
tech' Version.php
testwiki:  MediaWiki version: 1.44.0-wmf.1 (built: 23:47, 28 October 2024)
testwikidatawiki:  MediaWiki version: 1.44.0-wmf.1 (built: 23:47, 28 October 2024)
root@deploy2002:~# kubectl -n mw-debug exec mw-debug.eqiad.pinkunicorn-d67975fb5-kv2vs -c mediawiki-pinkunicorn-app -- mwscriptwikiset s1.dblist Version.php
enwiki:  MediaWiki version: 1.43.0-wmf.28 LTS (built: 00:09, 22 October 2024)
Clement_Goubert updated the task description. (Show Details)

Resolving as the general purpose helper scripts are now inside the image. Subtasks will track special cases.