Page MenuHomePhabricator

Delete .git/logs on zuul-merger git repo to prevent reflog from being created
Closed, ResolvedPublic

Description

fa07ec931b97227229528f962eb52646f1e80d51 sets git config core.logAllRefUpdates = false on the zuul merger. Looking at the repositories the reflog is still appended.

Rereading git-config(1) it is false by default in a bare repository, however if there is an entry in refs/logs/ it is still happening.

My theory (to be checked in the source code or empirically tested) is that deleting refs/logs/* would prevent them from being created with core.logAllRefUpdates = false

Event Timeline

On the Zuul merger instances (contint1001.wikimedia.org and contint2001.wikimedia.org) I have deleted the refs/logs for the test/gerrit-ping repository:

sudo rm -fR /srv/zuul/git/test/gerrit-ping/.git/logs

I then did a recheck of a dummy change https://gerrit.wikimedia.org/r/c/test/gerrit-ping/+/226272 but that resulted in reflog being added.

$ git -C /srv/zuul/git/test/gerrit-ping reflog --no-decorate
5ff6c28 HEAD@{0}: merge 5ff6c286749fa94c7f08a0c36c5272bad5fcc34e: Fast-forward
5794844 HEAD@{1}: reset: moving to HEAD
5ff6c28 HEAD@{2}: merge 5ff6c286749fa94c7f08a0c36c5272bad5fcc34e: Fast-forward
5794844 HEAD@{3}: reset: moving to HEAD

Rechecking the git configuration it is set to true instead of false:

$ sudo -H -u zuul git config --get core.logallrefupdates
true

Because it is set twice!

$ sudo -H -u zuul git config --list|grep -i logallref
core.logallrefupdates=false
core.logallrefupdates=true

Despite having:

/var/lib/zuul/.gitconfig
# git::systemconfig for '.gitconfig for Zuul merger'
[core]
logAllRefUpdates = false
[fetch]
prune = true
pruneTags = true

core.logallrefupdates is set to true in the local repository config, I believe that is done by git clone since it is a non-bare repository:

$ sudo -H -u zuul git -C /srv/zuul/git/test/gerrit-ping  config --list --show-origin|grep -i logallref
file:/var/lib/zuul/.gitconfig	core.logallrefupdates=false
file:.git/config	core.logallrefupdates=true

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

[operations/puppet@production] zuul: disable core.logAllRefUpdates at clone time

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

hashar triaged this task as Low priority.
hashar moved this task from INBOX to Doing on the Release-Engineering-Team board.

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

[operations/puppet@production] git: add define for abritrarily named config file

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

Change 791327 merged by Dzahn:

[operations/puppet@production] git: add define for abritrarily named config file

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

Change 790350 merged by Marostegui:

[operations/puppet@production] zuul: disable core.logAllRefUpdates at clone time

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

I tested the change by deleting the test/gerrit-ping repo on both zuul merger and doing a recheck, core.logallrefupdates is set to false in the freshly cloned git repo:

$ git  -C /srv/zuul/git/test/gerrit-ping config --list --show-origin|grep -i logallref
file:.git/config	core.logallrefupdates=false

The rest of the repo git config looks correct as well:

/srv/zuul/git/test/gerrit-ping/.git/config
[core]
	logAllRefUpdates = false    # <------- it is FALSE! :)
	repositoryformatversion = 0
	filemode = true
	bare = false
[remote "origin"]
	url = ssh://jenkins-bot@gerrit.wikimedia.org:29418/test/gerrit-ping
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
[user]
	email = zuul-merger@contint2001
	name = Wikimedia Zuul Merger

I now need a oneliner to update all the existing per repositories config to set `core.logallrefupdates to false.

Mentioned in SAL (#wikimedia-releng) [2022-06-22T09:00:56Z] <hashar> contint1001 , contint2002: setting core.logallrefupdates=false on all Zuul merger git repositories: sudo -u zuul find /srv/zuul/git -type d -name .git -print -execdir git config core.logallrefupdates false \; # T307620

Mentioned in SAL (#wikimedia-releng) [2022-06-22T09:08:11Z] <hashar> contint1001 , contint2002: deleting .git/logs from all zuul-merger repositories. We do not need the reflog sudo -u zuul find /srv/zuul/git -type d -name .git -print -execdir rm -fR .git/logs \; # T307620

Finally solved, the git reflog are no more created :]