Cloner: Don't fall back on infrastructure failure
Currently zuul-cloner falls back to the fallback branch when fetching
of the zuul ref fails. This is intended when the zuul ref is not found
on the remote. But in case the fetch fails due to infrastructure
reasons (e.g. zuul-merger is not reachable or certificate verification
failed) it should bail out with an error. Otherwise a already merged
and tested patch will be verified which could lead to broken patches
being merged.
Change-Id: Iefc82603de279e36ad5972ce341b102c8d38f69e
diff --git a/zuul/lib/cloner.py b/zuul/lib/cloner.py
index 257b95d..f0235a6 100644
--- a/zuul/lib/cloner.py
+++ b/zuul/lib/cloner.py
@@ -103,7 +103,14 @@
repo.fetchFrom(zuul_remote, ref)
self.log.debug("Fetched ref %s from %s", ref, project)
return True
- except (ValueError, GitCommandError):
+ except ValueError:
+ self.log.debug("Project %s in Zuul does not have ref %s",
+ project, ref)
+ return False
+ except GitCommandError as error:
+ # Bail out if fetch fails due to infrastructure reasons
+ if error.stderr.startswith('fatal: unable to access'):
+ raise
self.log.debug("Project %s in Zuul does not have ref %s",
project, ref)
return False