Page MenuHomePhabricator

Delete wmf branches from Gerrit repositories
Open, Needs TriagePublic2 Estimated Story Points

Description

As we cut more and more wmf branches, we should automatize the garbage collection of the branches from all repositories.

We once started a deletion with T244368 which got us a quick shell script delete-wmf-branches script.

T250095 made make-release to convert wmf branches to tags https://gerrit.wikimedia.org/r/c/mediawiki/tools/release/+/683934. Example usage:

branch.py --core --core-bundle wmf_core --bundle wmf_branch --delete <VERSION>

We have barely run it:

git ls-remote https://gerrit.wikimedia.org/r/mediawiki/core --headsrefs/heads/wmf/*
f12c3f71a3ea02f305770253afef2e4736b5af76	refs/heads/wmf/1.38.0-wmf.10
3eae43afcb2fe3adffa9201db67fd6f706e5ecc9	refs/heads/wmf/1.38.0-wmf.11
3283c039f723ffc7c66e646caa1534fbb5b6a6a7	refs/heads/wmf/1.38.0-wmf.12
be7254dc6ebf8bf8d7c2e81e166c026d0a1e112a	refs/heads/wmf/1.38.0-wmf.13
a9251939ca2b6ab9feadc5b9a4d6bf9c65526d6b	refs/heads/wmf/1.38.0-wmf.14
79173b685a5ad9bb9d4c8af30f7669731a9d6906	refs/heads/wmf/1.38.0-wmf.15
86035d5765bab50e741b58553ab62a40fd9d8033	refs/heads/wmf/1.38.0-wmf.16
a7e96ffb7ddca970d61ed334f62b625284956629	refs/heads/wmf/1.38.0-wmf.17
cd0a7969c8bdbffc35f151ea8023742b2670bbdc	refs/heads/wmf/1.38.0-wmf.18
aaac0d6a13a7c612b0759ee45751f0c5cb83b1dc	refs/heads/wmf/1.38.0-wmf.19
179b099f4da126086f547344f3d8c647acd008d5	refs/heads/wmf/1.38.0-wmf.2
ef9116432d8e7744c218167ad7f9d779f7f201a4	refs/heads/wmf/1.38.0-wmf.20
19ee29788b9445fbef6f643312916a92da580934	refs/heads/wmf/1.38.0-wmf.21
ba204e68a838ef4e11cc146f48e826831f035b32	refs/heads/wmf/1.38.0-wmf.22
2a7b91e8f53c0ffa2d0cec0478333f462303e171	refs/heads/wmf/1.38.0-wmf.23
a2be7506f8c9972baa685ff3d3d477fd19132671	refs/heads/wmf/1.38.0-wmf.24
eefd25b639d72cddec3473ce41a9bf82e11f2658	refs/heads/wmf/1.38.0-wmf.25
d797b02e58609f8ab242a940616d4c7829b9eec6	refs/heads/wmf/1.38.0-wmf.26
f03b0f73a105de57bd15fb49984b258c1a838b87	refs/heads/wmf/1.38.0-wmf.3
b9d44aab22a2668a28d539dc1d813bab994bef4e	refs/heads/wmf/1.38.0-wmf.4
2c7d643a5fa67c005e3dd1f015526bf21942ae9d	refs/heads/wmf/1.38.0-wmf.5
2b2d738ef2863fabea0f078959aee036a9e81230	refs/heads/wmf/1.38.0-wmf.6
85644d6274af2f748e5cabeeff8da7ae9a37febf	refs/heads/wmf/1.38.0-wmf.7
3934f55e6e02eb910ac12da1121b1ab83c2756a3	refs/heads/wmf/1.38.0-wmf.8
9aaa2218d225fb4e77d24b0a0f609791f5a06977	refs/heads/wmf/1.38.0-wmf.9

I suppose they are manually cleaned up from time to time T291501 was for 1.37 though they are not cleaned for all extensions/skins (AbuseFilter has branches since wmf/1.35.0-wmf.1).

Maybe they can be converted to tags (see above make-release branch.py supports that).

Event Timeline

There's delete-wmf-branches from T244368, but I was pretty sure we had a better one somewhere that handled the tag conversion.

@dancy or @thcipriani does this ring any bells I'm forgetting about?

https://gerrit.wikimedia.org/r/c/mediawiki/tools/release/+/683934 is where we modified branch.py to create a tag named after the branch before deleting the branch.

One can inspect all extensions and skins by cloning the mono repositories mediawiki/extensions and mediawiki/skins (warning: huge). I ran a little script to find the oldest branch on each repo:

earliest-wmf-branch
#!/bin/bash
oldest=$(git branch -lr --sort=version:refname 'origin/wmf/*'|head -n1)
if [ -n "$oldest" ]; then
    printf "| %s | %s\n" "$(basename "$(pwd)")" "${oldest/  /}"
fi

Did a prune of all remote branches with git submodule foreach git remote prune origin

Then git -C ~/projects/mediawiki/extensions submodule foreach -q ../earliest-wmf-branch yields:

Skins

CologneBlueorigin/wmf/1.36.0-wmf.20
MinervaNeueorigin/wmf/1.35.0-wmf.1
Modernorigin/wmf/1.29.0-wmf.21
MonoBookorigin/wmf/1.29.0-wmf.21
Nostalgiaorigin/wmf/1.29.0-wmf.21
Timelessorigin/wmf/1.35.0-wmf.1
Vectororigin/wmf/1.36.0-wmf.10
WikimediaApiPortalorigin/wmf/1.35.0-wmf.40

Extensions

3Dorigin/wmf/1.35.0-wmf.1
AbuseFilterorigin/wmf/1.35.0-wmf.1
ActiveAbstractorigin/wmf/1.35.0-wmf.1
AdvancedSearchorigin/wmf/1.35.0-wmf.1
AntiSpooforigin/wmf/1.35.0-wmf.1
ApiFeatureUsageorigin/wmf/1.35.0-wmf.1
ArticleCreationWorkfloworigin/wmf/1.35.0-wmf.1
ArticlePlaceholderorigin/wmf/1.35.0-wmf.1
Babelorigin/wmf/1.35.0-wmf.1
BetaFeaturesorigin/wmf/1.35.0-wmf.1
BounceHandlerorigin/wmf/1.35.0-wmf.1
Calendarorigin/wmf/1.35.0-wmf.1
Campaignsorigin/wmf/1.35.0-wmf.1
Capiuntoorigin/wmf/1.35.0-wmf.1
CategoryTreeorigin/wmf/1.35.0-wmf.1
CentralAuthorigin/wmf/1.35.0-wmf.1
CentralNoticeorigin/wmf/1.38.0-wmf.1
CharInsertorigin/wmf/1.35.0-wmf.1
CheckUserorigin/wmf/1.35.0-wmf.1
ChessBrowserorigin/wmf/1.37.0-wmf.3
CirrusSearchorigin/wmf/1.35.0-wmf.1
Citeorigin/wmf/1.35.0-wmf.1
CiteThisPageorigin/wmf/1.35.0-wmf.1
Citoidorigin/wmf/1.35.0-wmf.1
CodeEditororigin/wmf/1.35.0-wmf.1
CodeMirrororigin/wmf/1.35.0-wmf.1
CodeRevieworigin/wmf/1.35.0-wmf.1
Cognateorigin/wmf/1.35.0-wmf.1
CollaborationKitorigin/wmf/1.34.0-wmf.13
Collectionorigin/wmf/1.34.0-wmf.13
CommonsMetadataorigin/wmf/1.34.0-wmf.13
ConfirmEditorigin/wmf/1.34.0-wmf.13
CongressLookuporigin/wmf/1.34.0-wmf.13
ContactPageorigin/wmf/1.34.0-wmf.13
ContentTranslationorigin/wmf/1.34.0-wmf.13
CreditsSourceorigin/wmf/1.34.0-wmf.13
Dashikiorigin/wmf/1.34.0-wmf.13
Disambiguatororigin/wmf/1.34.0-wmf.13
DiscussionToolsorigin/wmf/1.35.0-wmf.4
DismissableSiteNoticeorigin/wmf/1.34.0-wmf.13
DonationInterfaceorigin/wmf/1.35.0-wmf.1
DoubleWikiorigin/wmf/1.34.0-wmf.13
DynamicSidebarorigin/wmf/1.34.0-wmf.13
Echoorigin/wmf/1.34.0-wmf.13
Elasticaorigin/wmf/1.34.0-wmf.13
ElectronPdfServiceorigin/wmf/1.34.0-wmf.13
EntitySchemaorigin/wmf/1.34.0-wmf.4
EventBusorigin/wmf/1.34.0-wmf.13
EventLoggingorigin/wmf/1.34.0-wmf.13
EventStreamConfigorigin/wmf/1.35.0-wmf.14
ExtensionDistributororigin/wmf/1.34.0-wmf.13
ExternalGuidanceorigin/wmf/1.34.0-wmf.13
FeaturedFeedsorigin/wmf/1.34.0-wmf.13
FileExporterorigin/wmf/1.34.0-wmf.13
FileImporterorigin/wmf/1.34.0-wmf.13
FlaggedRevsorigin/wmf/1.34.0-wmf.13
Floworigin/wmf/1.34.0-wmf.13
FundraiserLandingPageorigin/wmf/1.34.0-wmf.13
FundraisingTranslateWorkfloworigin/wmf/1.34.0-wmf.13
GWToolsetorigin/wmf/1.34.0-wmf.13
Gadgetsorigin/wmf/1.34.0-wmf.13
GeoCrumbsorigin/wmf/1.34.0-wmf.13
GeoDataorigin/wmf/1.34.0-wmf.13
GettingStartedorigin/wmf/1.34.0-wmf.13
GlobalBlockingorigin/wmf/1.34.0-wmf.13
GlobalCssJsorigin/wmf/1.34.0-wmf.13
GlobalPreferencesorigin/wmf/1.34.0-wmf.13
GlobalUsageorigin/wmf/1.34.0-wmf.13
GlobalUserPageorigin/wmf/1.34.0-wmf.13
GlobalWatchlistorigin/wmf/1.36.0-wmf.7
GoogleNewsSitemaporigin/wmf/1.34.0-wmf.13
Graphorigin/wmf/1.35.0-wmf.1
GrowthExperimentsorigin/wmf/1.35.0-wmf.1
GuidedTourorigin/wmf/1.35.0-wmf.1
IPInfoorigin/wmf/1.36.0-wmf.21
ImageMaporigin/wmf/1.35.0-wmf.1
InputBoxorigin/wmf/1.35.0-wmf.1
Insiderorigin/wmf/1.34.0-wmf.13
Interwikiorigin/wmf/1.35.0-wmf.1
InterwikiSortingorigin/wmf/1.35.0-wmf.1
Josaorigin/wmf/1.34.0-wmf.13
JsonConfigorigin/wmf/1.35.0-wmf.1
Kartographerorigin/wmf/1.35.0-wmf.1
LabeledSectionTransclusionorigin/wmf/1.34.0-wmf.13
LandingCheckorigin/wmf/1.34.0-wmf.13
LdapAuthenticationorigin/wmf/1.35.0-wmf.1
Linterorigin/wmf/1.35.0-wmf.1
LiquidThreadsorigin/wmf/1.35.0-wmf.18
Listingsorigin/wmf/1.34.0-wmf.13
LocalisationUpdateorigin/wmf/1.34.0-wmf.13
LoginNotifyorigin/wmf/1.35.0-wmf.1
MachineVisionorigin/wmf/1.35.0-wmf.1
MapSourcesorigin/wmf/1.35.0-wmf.1
MassMessageorigin/wmf/1.35.0-wmf.1
Mathorigin/wmf/1.35.0-wmf.1
MediaModerationorigin/wmf/1.35.0-wmf.35
MediaSearchorigin/wmf/1.37.0-wmf.2
MobileApporigin/wmf/1.34.0-wmf.13
MobileFrontendorigin/wmf/1.35.0-wmf.1
MultimediaViewerorigin/wmf/1.35.0-wmf.1
NavigationTimingorigin/wmf/1.38.0-wmf.1
NearbyPagesorigin/wmf/1.37.0-wmf.20
NewUserMessageorigin/wmf/1.35.0-wmf.1
Newsletterorigin/wmf/1.35.0-wmf.1
Nukeorigin/wmf/1.35.0-wmf.1
OATHAuthorigin/wmf/1.35.0-wmf.1
OAuthorigin/wmf/1.35.0-wmf.1
OAuthRateLimiterorigin/wmf/1.36.0-wmf.2
ORESorigin/wmf/1.35.0-wmf.1
OpenStackManagerorigin/wmf/1.35.0-wmf.1
PageAssessmentsorigin/wmf/1.35.0-wmf.1
PageImagesorigin/wmf/1.35.0-wmf.1
PageNoticeorigin/wmf/1.36.0-wmf.30
PageTriageorigin/wmf/1.35.0-wmf.1
PageViewInfoorigin/wmf/1.35.0-wmf.1
PagedTiffHandlerorigin/wmf/1.35.0-wmf.1
ParserFunctionsorigin/wmf/1.35.0-wmf.1
PdfHandlerorigin/wmf/1.35.0-wmf.1
PerformanceInspectororigin/wmf/1.34.0-wmf.13
Petitionorigin/wmf/1.35.0-wmf.1
Poemorigin/wmf/1.34.0-wmf.13
PoolCounterorigin/wmf/1.34.0-wmf.13
Popupsorigin/wmf/1.35.0-wmf.1
ProofreadPageorigin/wmf/1.35.0-wmf.1
PropertySuggesterorigin/wmf/1.35.0-wmf.1
QuickSurveysorigin/wmf/1.34.0-wmf.13
Quizorigin/wmf/1.35.0-wmf.1
RSSorigin/wmf/1.35.0-wmf.1
ReadingListsorigin/wmf/1.34.0-wmf.13
RelatedArticlesorigin/wmf/1.35.0-wmf.1
Renameuserorigin/wmf/1.35.0-wmf.1
RevisionSliderorigin/wmf/1.35.0-wmf.1
SandboxLinkorigin/wmf/1.35.0-wmf.1
Scoreorigin/wmf/1.35.0-wmf.1
Scribuntoorigin/wmf/1.35.0-wmf.1
SearchExtraNSorigin/wmf/1.34.0-wmf.13
SecureLinkFixerorigin/wmf/1.35.0-wmf.1
SecurePollorigin/wmf/1.35.0-wmf.1
Sentryorigin/wmf/1.34.0-wmf.13
ShortUrlorigin/wmf/1.34.0-wmf.13
SiteMatrixorigin/wmf/1.34.0-wmf.13
SkinPerPageorigin/wmf/1.34.0-wmf.13
SpamBlacklistorigin/wmf/1.35.0-wmf.1
StopForumSpamorigin/wmf/1.36.0-wmf.23
SubPageList3origin/wmf/1.34.0-wmf.13
SubpageSortkeyorigin/wmf/1.34.0-wmf.13
SyntaxHighlight_GeSHiorigin/wmf/1.35.0-wmf.1
TemplateDataorigin/wmf/1.36.0-wmf.10
TemplateSandboxorigin/wmf/1.35.0-wmf.1
TemplateStylesorigin/wmf/1.35.0-wmf.1
TemplateWizardorigin/wmf/1.32.0-wmf.18
TextExtractsorigin/wmf/1.35.0-wmf.1
Thanksorigin/wmf/1.35.0-wmf.1
TheWikipediaLibraryorigin/wmf/1.35.0-wmf.1
TimedMediaHandlerorigin/wmf/1.35.0-wmf.1
TitleBlacklistorigin/wmf/1.35.0-wmf.1
TocTreeorigin/wmf/1.34.0-wmf.13
TorBlockorigin/wmf/1.35.0-wmf.1
Translateorigin/wmf/1.35.0-wmf.1
TranslationNotificationsorigin/wmf/1.35.0-wmf.1
TrustedXFForigin/wmf/1.34.0-wmf.13
TwoColConflictorigin/wmf/1.35.0-wmf.1
UniversalLanguageSelectororigin/wmf/1.35.0-wmf.1
UploadWizardorigin/wmf/1.35.0-wmf.1
UploadsLinkorigin/wmf/1.34.0-wmf.13
UrlShortenerorigin/wmf/1.35.0-wmf.1
UserMergeorigin/wmf/1.35.0-wmf.1
VipsScalerorigin/wmf/1.34.0-wmf.13
VisualEditororigin/wmf/1.35.0-wmf.1
WebAuthnorigin/wmf/1.35.0-wmf.2
WikiEditororigin/wmf/1.35.0-wmf.1
WikiLambdaorigin/wmf/1.38.0-wmf.4
WikiLoveorigin/wmf/1.36.0-wmf.1
Wikibaseorigin/wmf/1.35.0-wmf.1
WikibaseCirrusSearchorigin/wmf/1.35.0-wmf.30
WikibaseLexemeorigin/wmf/1.35.0-wmf.1
WikibaseLexemeCirrusSearchorigin/wmf/1.34.0-wmf.13
WikibaseMediaInfoorigin/wmf/1.35.0-wmf.1
WikibaseQualityConstraintsorigin/wmf/1.35.0-wmf.1
Wikidata.orgorigin/wmf/1.35.0-wmf.1
WikidataPageBannerorigin/wmf/1.35.0-wmf.1
WikimediaApiPortalOAuthorigin/wmf/1.35.0-wmf.40
WikimediaBadgesorigin/wmf/1.35.0-wmf.1
WikimediaEditorTasksorigin/wmf/1.35.0-wmf.1
WikimediaEventsorigin/wmf/1.36.0-wmf.33
WikimediaIncubatororigin/wmf/1.35.0-wmf.1
WikimediaMaintenanceorigin/wmf/1.34.0-wmf.13
WikimediaMessagesorigin/wmf/1.35.0-wmf.1
Wikisourceorigin/wmf/1.35.0-wmf.4
XAnalyticsorigin/wmf/1.34.0-wmf.13
cldrorigin/wmf/1.32.0-wmf.25
intersectionorigin/wmf/1.35.0-wmf.1
timelineorigin/wmf/1.35.0-wmf.1
wikihieroorigin/wmf/1.35.0-wmf.1
dduvall set the point value for this task to 2.Mar 16 2022, 5:56 PM

Change 771955 had a related patch set uploaded (by Hashar; author: Hashar):

[mediawiki/tools/release@master] make-release: add test for delete_branch

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

Change 771956 had a related patch set uploaded (by Hashar; author: Hashar):

[mediawiki/tools/release@master] make-release: abort branch deletion if tag failed

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

I have looked at the make-release/branch.py script and it has support to delete old branches. Unfortunately while reading the code and testing it (with --noop) I found several issues with errors handling. Notably:

  • when the tag fails to be created, we still delete the branch
  • a non existing branch on one of the repo abort the script execution (so it is not rentrant when processing a bundle)

I have added some tests and made a change to prevent deleting a branch when the tag failed to create. That is a start.

Another one is that repositories which are no more deployed to Wikimedia are unknown to the branch.py script and would thus never have their old wmf branches collected.

There was also a concern about tags piling up, I guess we can move them to refs/attic/tags/* so we still have them around if needed. But that is a different discussion.

Change 771955 merged by jenkins-bot:

[mediawiki/tools/release@master] make-release: add test for delete_branch

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

Change 771956 merged by jenkins-bot:

[mediawiki/tools/release@master] make-release: abort branch deletion if tag failed

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

Change 773504 had a related patch set uploaded (by Hashar; author: Hashar):

[mediawiki/tools/release@master] make-release: hardened branch existence detection

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

Change 773504 merged by jenkins-bot:

[mediawiki/tools/release@master] make-release: hardened branch existence detection

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

I am unassigning myself since I have way too many tasks to juggle with. To resume I think we would need to:

A) decide whether we delete old wmf branches or convert them to tags. I thought deleting the branch would cause the old refs to be garbage collected, but they are still associated with a change in Gerrit (refs/changes/YY/XXXYY/Z) which is sufficient to hold them in the repos

B) enhance the script to act on a list of branches (possibly a wildcard) we want to act on instead of on a per branch basis

I currently have the following aliases (dotfiles repo):

	# Wildcard deletion of remote branches
	#
	# Usage: git remote-wildcard-br-d 'wmf/1.36*'
	# Usage: git remote-<tab>
	#
	# Inspired by <https://stackoverflow.com/q/3670355/319266>
	#
	# Note that git-push requires its branch argument to be without the
	# localised "refs/remotes/origin" prefix. As such, we strip that off.
	#
	# $ git branch -rl 'origin/wmf/1.36*' --format '%(refname)'
	# $ git branch -rl 'origin/wmf/1.36*' --format '%(refname:lstrip=3)'
	# $ git push origin --delete
	#
	remote-wildcard-br-d = "!f() { git branch -rl \"origin/$1\" --format '%(refname:lstrip=3)' | xargs git push origin --delete; }; f"

And have removed the old branches again on various repos including mediawiki/core, so as to de-clutter interfaces such as the "Cherry pick" dialog etc

Mentioned in SAL (#wikimedia-releng) [2022-08-16T19:17:38Z] <Krinkle> mediawiki/extensions/Scribunto$ git remote-wildcard-br-d 'wmf/1.35*' # ref T303828

Mentioned in SAL (#wikimedia-releng) [2022-09-06T00:20:09Z] <Krinkle> Prune various old mediawiki/core wmf branches for Gerrit usability, ref T303828

dancy removed dancy as the assignee of this task.Sep 19 2022, 4:04 PM

The branch are no more cleaned since T218783 which moved the logic behind a feature flag (scap clean --delete-gerrit-branch) due to some weird breakage related to ssh auth socket. If that T218783 is investigated again and fixed, that would clean out the old branch and I solve this one.