fetch: Add log_errors parameter to Fetch.download()
PATCH 1/1 fetch: Add log_errors parameter to Fetch.download()
From: 张强 <[email protected]>
Fetching an sstate object from a mirror can fail transiently and is recoverable when the caller falls back to running the real task. The unconditional logger.error() in download() makes bitbake exit non-zero even though every task ends up succeeding, as bitbake counts any ERROR message towards its exit code.
Add a log_errors parameter so such callers can request the first fetch failure to be logged at WARNING instead of ERROR. The default (True) keeps the current behaviour for all existing callers.
Signed-off-by 张强 <[email protected]>
--- lib/bb/fetch/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
lib/bb/fetch/__init__.py +8 -2
@@ -1884,9 +1884,12 @@ class Fetch(object): return local - def download(self, urls=None): + def download(self, urls=None, log_errors=True): """ Fetch all urls + + log_errors=False logs the first fetch failure at WARNING instead of + ERROR, for callers that treat a fetch failure as recoverable. """ if not urls: urls = self.urls
@@ -1957,7 +1960,10 @@ class Fetch(object): if not done or not m.done(ud, d): if firsterr: - logger.error(str(firsterr)) + if log_errors: + logger.error(str(firsterr)) + else: + logger.warning(str(firsterr)) raise FetchError("Unable to fetch URL from any source.", u) m.update_donestamp(ud, d)
Signature · 1 line
2.25.1