Page MenuHomePhabricator

mwgrep cannot be used from a deployment host
Closed, ResolvedPublic

Description

We have the mwgrep script that allows those with mwmaint access to search across all gadgets and user scripts at all wikis (including private ones). This is useful when deciding whether a certain feature can be removed or altered, or how many (or which) gadgets that would affect. Today, I discovered this command is installed at the deployment host, but it does not work:

[urbanecm@deploy2002 ~]$ mwgrep
/usr/bin/env: ‘python’: No such file or directory
[urbanecm@deploy2002 ~]$

I tried running the script with python3 manually, but then I ran into unavailable Python modules:

[urbanecm@deploy2002 ~]$ which mwgrep
/usr/local/bin/mwgrep
[urbanecm@deploy2002 ~]$ python3 /usr/local/bin/mwgrep
Traceback (most recent call last):
  File "/usr/local/bin/mwgrep", line 30, in <module>
    reload(sys)
NameError: name 'reload' is not defined
[urbanecm@deploy2002 ~]$

I'm not 100% sure if we plan to keep or remove the maintenance host (where the script works as intended). However, we should either remove the script from the deployment host, or make it work there as well.

Event Timeline

RLazarus subscribed.

This isn't working because it was never upgraded to Python 3. (reload was a built-in function in Python 2, moved to importlib in 3.) The mwmaint hosts are still running buster, so Python 2 is available, but the deploy hosts are on bullseye.

If we want the script to work, it'll need to be converted to Python 3. This was attempted in https://gerrit.wikimedia.org/r/565800 but reverted in https://gerrit.wikimedia.org/r/741138, and it looks like nobody's tried again since.

(I'm tagging ServiceOps in a clinic duty capacity, as the most likely relevant SRE team -- but in my serviceops capacity, I'm not sure offhand whether we'll actually take up this work.)

jijiki triaged this task as Medium priority.Feb 3 2025, 1:27 PM
jijiki moved this task from Incoming 🐫 to 🌻Mediawiki on the serviceops-deprecated board.

Change #1127075 had a related patch set uploaded (by Reedy; author: Reedy):

[operations/puppet@production] Revert^2 "scap: Port mwgrep to Python 3 and other cleanup"

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

Change #1127075 merged by Majavah:

[operations/puppet@production] Revert^2 "scap: Port mwgrep to Python 3 and other cleanup"

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

Change #1127075 had a related patch set uploaded (by Reedy; author: Reedy):

[operations/puppet@production] Revert^2 "scap: Port mwgrep to Python 3 and other cleanup"

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

So is this now Resolved? Do any docs need updating?

Reedy claimed this task.

Nope, all good.