Page MenuHomePhabricator

Create a way to temporarily bypass the results cache on production
Closed, ResolvedPublic

Description

What/Why:
There are times we need to turn off the caching functionality in WikiLambda when invoking functions in Production. The argument $bypassCache stored in extensions/WikiLambda/includes/OrchestratorRequest.php ~L51. It would be useful to have a way to do this via an environment variable or something.

How:

  1. Find best way to to do this and figure out implementation details
  2. Add to doc or create a patch to introduce new env var or config/script.

Resources: https://wikitech.wikimedia.org/wiki/Wikifunctions/Runbook#Add_a_new_pre-defined_Object_in_production

Event Timeline

Jdforrester-WMF renamed this task from Create a way to toggle cache in Production to Create a way to bypass the results cache, even in production.Nov 13 2024, 5:36 PM
Jdforrester-WMF added a project: Design.
Jdforrester-WMF subscribed.

I'm extremely uneasy about creating things kind of security vector, and would need quite a lot of product/design work to decide how to expose it and explain how dangerous it was to use.

@Jdforrester-WMF - Thanks for commenting. Understood about the security concerns, of course. Grace and I were thinking this might be acceptable if it's set up as a maintenance script, similar to loadPreDefinedObject.php, and requires shelling into a development server to run it. Also, it could be coded in such a way that it would never take effect more than, say, 15 minutes at a time. Also, I wonder if maybe the script could bypass caching only for requests coming from one specified user.

DMartin-WMF renamed this task from Create a way to bypass the results cache, even in production to Create a way to temporarily bypass the results cache on production.Nov 19 2024, 3:25 AM

note/ideas:

  • create/add an env var to pass as boolean value to the $bypassCache argument in orchestrate() function in /WikiLambda/includes/OrchestratorRequest.php
  • make boolean pass-able during a function call/request6
  • good to add a time limit?
  • permissions: local wikifunctions-staff group (not global staff)

Change #1111736 had a related patch set uploaded (by Ecarg; author: Ecarg):

[mediawiki/extensions/WikiLambda@master] Add a way to toggle caching for testing purposes

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

@ecarg and I talk about this a bit on Slack. Could we protect this behind the global staff group or a similar, internal right/group? I know that's probably a bit ugly, but it's a battle-tested and auditable approach.

sbassett added a project: SecTeam-Processed.

Per discussion on the AW-Sec call this morning, the Security-Team would currently rate the new, time-limited right/role solution as low risk.

ecarg changed the task status from Open to In Progress.Jan 27 2025, 9:07 PM

Change #1111736 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Add a way to toggle caching for testing purposes

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

Change #1121385 had a related patch set uploaded (by Jforrester; author: Jforrester):

[operations/mediawiki-config@master] [wikifunctionswiki] Give wikilambda-bypass-cache to staff

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

Change #1121385 merged by jenkins-bot:

[operations/mediawiki-config@master] [wikifunctionswiki] Give wikilambda-bypass-cache to staff

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

Mentioned in SAL (#wikimedia-operations) [2025-02-20T21:23:49Z] <jforrester@deploy2002> Started scap sync-world: Backport for [[gerrit:1121385|[wikifunctionswiki] Give wikilambda-bypass-cache to staff (T379432)]]

Mentioned in SAL (#wikimedia-operations) [2025-02-20T21:26:34Z] <jforrester@deploy2002> jforrester: Backport for [[gerrit:1121385|[wikifunctionswiki] Give wikilambda-bypass-cache to staff (T379432)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2025-02-20T21:33:24Z] <jforrester@deploy2002> Finished scap sync-world: Backport for [[gerrit:1121385|[wikifunctionswiki] Give wikilambda-bypass-cache to staff (T379432)]] (duration: 09m 34s)

Tested in production and this works well. Thanks, all!

@Jdforrester-WMF If it has already been tested, can we sign off, or do you need @ecarg to do so?

Yeah, let's declare this Resolved.