diff options
author | Peter Marko <peter.marko@siemens.com> | 2023-07-11 08:36:28 +0200 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-07-13 07:03:17 -1000 |
commit | 6c5b006a10995cf6a4fa99006f6e825ac8f3a69d (patch) | |
tree | a98154c2ff88f615b5fa2536159d50c068a903fa | |
parent | 5e9e50e5445cc64aad085a62abb260cc318817a9 (diff) | |
download | poky-6c5b006a10995cf6a4fa99006f6e825ac8f3a69d.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: 8bba9342f641e9aa51ccaebc02bc5d51354e1c72)
Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 88dad8f198baa80af5ab576498f4df6ed639d551)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r-- | meta/recipes-core/meta/cve-update-nvd2-native.bb | 11 |
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 |