Disable fetching of changed submodules

By default Git will always attempt to fetch changed submodules (a
submodule that has commits that are referenced by a newly fetched
superproject commit but are missing in the local submodule clone) as the
default for the 'recurse-submodules' option is 'on-demand'.

Change this to never recurse submodules so we don't run into the below
fetch error (those are transient and will self-resolve on the next
attempt):

ERROR zuul.AnsibleJob: [e: ...] [build: ...] Retry 1: Fetch /path/to/workspace/repo origin refs/pull/123/head
Traceback (most recent call last):
  File "/opt/zuul/lib/python3.13/site-packages/zuul/merger/merger.py", line 303, in _git_fetchInner
    repo.git.fetch(remote, ref_to_fetch,
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
                   kill_after_timeout=self.git_timeout, f=True,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                   **kwargs)
                   ^^^^^^^^^
  File "/opt/zuul/lib/python3.13/site-packages/git/cmd.py", line 736, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
                                   ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/zuul/lib/python3.13/site-packages/git/cmd.py", line 1316, in _call_process
    return self.execute(call, **exec_kwargs)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/opt/zuul/lib/python3.13/site-packages/git/cmd.py", line 1111, in execute
    raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git fetch -f origin refs/pull/123/head:refs/zuul/fetch
  stderr: 'From https://github/org/project
 * [new ref]             refs/pull/123/head -> refs/zuul/fetch
Could not access submodule 'foo/bar'
Could not access submodule 'abc/123'

Change-Id: I14ced19735d438c9ed67630e2fc4bbe2aeac3a70
This commit is contained in:
Simon Westphahl
2026-05-05 15:55:40 +02:00
parent 3be8e2c4c1
commit d40ef748f2
+1 -1
View File
@@ -302,7 +302,7 @@ class Repo(object):
ref_to_fetch += ':refs/zuul/fetch'
repo.git.fetch(remote, ref_to_fetch,
kill_after_timeout=self.git_timeout, f=True,
**kwargs)
no_recurse_submodules=True, **kwargs)
return True
except Exception as e:
if attempt < self.retry_attempts: