Page MenuHomePhabricator

Scap should delete files after other updates
Closed, DeclinedPublic

Description

Today while deploying https://gerrit.wikimedia.org/r/537220 (for T223602), I accidentally forgot one extra level of splitting up.

The commit essentially does three things: Create IS.php, update CS.php reference from VS.php to IS.php, delete VS.php.

I synced it as:

  • scap sync-file wmf-config/IS.php '3373247e123b53 - create new file'
  • scap sync-dir wmf-config/

What I should have done is:

  • scap sync-file wmf-config/IS.php '3373247e123b53 - create new file'
  • scap sync-file wmf-config/CS.php
  • scap sync-dir wmf-config/ (implicitly deletes old VS.php)

I thought forwards but forgot to think backwards as well. While all servers had the new file, due to the race in rsync deleting VS.php and updating CS.php, it were possible for servers to have VS.php delete first (thus fatalling all MW backend traffic), and receive the update to CS.php afterwards.

This is exactly what happened. There wasn't anything I could or had to do about it, as by the end of the sync it would all be fine again.

However, during the 30-40 seconds of the last step of the deploy, Logstash recorded 1,964 fatal errors due to VariantSettings.php not existing.

Looks like this wasn't the first time it has happened, either:

In T22085#253058, @ori wrote:

Today's mobile deployment removed SkinMobileBase.php from MobileFrontend, a file that was previously loaded on every request. This provided an illustration of the problem and gives some sense of its magnitude. [..]

Using rsync's --delete-after or --delete-delayed option would not make scap atomic, but it could still significantly reduce the rate at which these kinds of errors occur.

So, let's set this option inside Scap!

Event Timeline

I'm not sure this is generalisably the behaviour we want.

Hm.. yeah, --delete-delay might not be the right answer here.

I think, the "perfect" answer is "Don't do this", because we're supposed to split things up if they are intertwined in this manner.

But I think something like --delete-after` would make for a better default. I can think of two scenario where it would behave in positive manner if a file is deleted first (e.g. if the file was already unused, or if it plays into some kind of auto-discovery). However both of those scenarios also work positively if the file is deleted after other changes.

I can't think of a scenario where it is explicitly required for a file to stop existing before updating code in other files. Or perhaps less strongly - can we agree that as a fallback for when someone has already screwed up (like me), that is is far more probable things turn out better if we sync changed and created files before deletion of files?

dancy subscribed.

Irrelevant in the k8s deployment world.