diff options
author | Simon Westphahl <simon.westphahl@bmw.de> | 2022-11-14 15:18:12 +0100 |
---|---|---|
committer | Simon Westphahl <simon.westphahl@bmw.de> | 2022-11-15 07:03:21 +0100 |
commit | b17dfc13ed72b9d58b53952cc88d15343be2329d (patch) | |
tree | cb54dc1b74d113808451e325d6788e2d7b17d688 /tests | |
parent | 35e5c4ce39970cb415d30bec7157be1807bee137 (diff) | |
download | zuul-b17dfc13ed72b9d58b53952cc88d15343be2329d.tar.gz |
Cleanup leaked git index.lock files on checkout
When the git command crashes or is aborted due to a timeout we might end
up with a leaked index.lock file in the affected repository.
This has the effect that all subsequent git operations that try to
create the lock will fail. Since Zuul maintains a separate lock for
serializing operations on a repositotry, we can be sure that the lock
file was leaked in a previous operation and can be removed safely.
Unable to checkout 8a87ff7cc0d0c73ac14217b653f9773a7cfce3a7
Traceback (most recent call last):
File "/opt/zuul/lib/python3.10/site-packages/zuul/merger/merger.py", line 1045, in _mergeChange
repo.checkout(ref, zuul_event_id=zuul_event_id)
File "/opt/zuul/lib/python3.10/site-packages/zuul/merger/merger.py", line 561, in checkout
repo.head.reset(working_tree=True)
File "/opt/zuul/lib/python3.10/site-packages/git/refs/head.py", line 82, in reset
self.repo.git.reset(mode, commit, '--', paths, **kwargs)
File "/opt/zuul/lib/python3.10/site-packages/git/cmd.py", line 542, in <lambda>
return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
File "/opt/zuul/lib/python3.10/site-packages/git/cmd.py", line 1005, in _call_process
return self.execute(call, **exec_kwargs)
File "/opt/zuul/lib/python3.10/site-packages/git/cmd.py", line 822, in execute
raise GitCommandError(command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git reset --hard HEAD --
stderr: 'fatal: Unable to create '/var/lib/zuul/merger-git/github/foo/foo%2Fbar/.git/index.lock': File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.'
Change-Id: I97334383df476809c39e0d03b1af50cb59ee0cc7
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_merger_repo.py | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/tests/unit/test_merger_repo.py b/tests/unit/test_merger_repo.py index 182dea120..fd78726ab 100644 --- a/tests/unit/test_merger_repo.py +++ b/tests/unit/test_merger_repo.py @@ -960,10 +960,6 @@ class TestMerger(ZuulTestCase): self.waitUntilSettled() self.assertEqual(A.data['status'], 'MERGED') - # Stop the merger so we can modify the git repo - self.merge_server.stop() - self.merge_server.join() - # Add an index.lock file fpath = os.path.join(self.merger_src_root, 'review.example.com', 'org', 'org%2Fproject1', '.git', 'index.lock') @@ -971,9 +967,6 @@ class TestMerger(ZuulTestCase): pass self.assertTrue(os.path.exists(fpath)) - # Start a new merger and check that we can still merge things - self._startMerger() - # This will fail if git can't modify the repo due to a stale lock file. B = self.fake_gerrit.addFakeChange('org/project1', 'master', 'B') B.addApproval('Code-Review', 2) |