Page MenuHomePhabricator

Functional replacement for `sql` on Kubernetes
Closed, ResolvedPublic

Description

On the maintenance hosts, the sql bash script launches the mysql.php maintenance script. Together, both wrappers just construct appropriate flags for mysql and then shell out to it. (docs)

In the mw-on-k8s world, we can't just use mwscript-k8s --attach to run the maintenance script, because mysql isn't installed in the multiversion MW image. (We could build another image and use that, but it's not clear that we need the added complexity.)

The simplest approach is probably to write a replacement in Python that shells out to mysql directly, basically doing the same argv construction as mysql.php, but reading dbconfig objects from etcd, à la dbctl. This can run locally, it doesn't need to involve the mwscript apparatus at all. (But because the existing solution is run on the mwmaint hosts, we should consider it a blocker for turning those hosts off.)

Event Timeline

With the new mwscript system, I find myself more often on the deployment host. Technically, I can run sql / mysql.php there as well, so I sometimes do that. However, the sql prompt is very different. Compare:

[urbanecm@mwmaint2002 ~]$ sql enwiki
[...]

wikiadmin2023@10.192.0.225(enwiki)> Bye
[urbanecm@mwmaint2002 ~]$

and

[urbanecm@deploy2002 ~]$ sql enwiki
[...]

MariaDB [enwiki]> ^DBye
[urbanecm@deploy2002 ~]$

I like mwmaint's prompt version, as it allows me to see what host I am on (and what permissions I operate under, in case I login to a non-MW database).

Can the new solution for sql also have mwmaint-type DB prompt?

Clement_Goubert claimed this task.
Clement_Goubert subscribed.

I think that's working correctly now that we installed the mysql client lib in the mediawiki-cli image and the correct prompt profile, resolving, but feel free to reopen if I'm mistaken.