summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Marko <peter.marko@siemens.com>2023-07-11 08:36:28 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-07-13 07:55:19 +0100
commit12373c8c4765fe2f1f98d2516ab42454a869e742 (patch)
treef5399ecf9a6f5183918dd4e79d147f53809c6fb8
parent62a436ed98e6d1f992dc93c3452ea355c2b9b188 (diff)
downloadpoky-12373c8c4765fe2f1f98d2516ab42454a869e742.tar.gz
cve-update-nvd2-native: retry all errors and sleep between retries
Last couple days it is not possible to update NVD DB as servers are returning lot of errors. Mostly "HTTP Error 503: Service Unavailable" is observed but sporadially also some others. Retrying helps in most cases, so extend retries to all errors. Additionally add sleep which is recommended by NVD between requests. These retries are already implemented between successful requests, but giving servers time between failed ones is important, too. (From OE-Core rev: 88dad8f198baa80af5ab576498f4df6ed639d551) Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/meta/cve-update-nvd2-native.bb11
1 files changed, 4 insertions, 7 deletions
diff --git a/meta/recipes-core/meta/cve-update-nvd2-native.bb b/meta/recipes-core/meta/cve-update-nvd2-native.bb
index c85df23f59..e2584d21b3 100644
--- a/meta/recipes-core/meta/cve-update-nvd2-native.bb
+++ b/meta/recipes-core/meta/cve-update-nvd2-native.bb
@@ -119,6 +119,7 @@ def nvd_request_next(url, api_key, args):
119 import urllib.parse 119 import urllib.parse
120 import gzip 120 import gzip
121 import http 121 import http
122 import time
122 123
123 headers = {} 124 headers = {}
124 if api_key: 125 if api_key:
@@ -140,13 +141,9 @@ def nvd_request_next(url, api_key, args):
140 141
141 r.close() 142 r.close()
142 143
143 except UnicodeDecodeError: 144 except Exception as e:
144 # Received garbage, retry 145 bb.debug(2, "CVE database: received error (%s), retrying (request: %s)" %(e, full_request))
145 bb.debug(2, "CVE database: received malformed data, retrying (request: %s)" %(full_request)) 146 time.sleep(6)
146 pass
147 except http.client.IncompleteRead:
148 # Read incomplete, let's try again
149 bb.debug(2, "CVE database: received incomplete data, retrying (request: %s)" %(full_request))
150 pass 147 pass
151 else: 148 else:
152 return raw_data 149 return raw_data