]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
cve-update-nvd2-native: retry all errors and sleep between retries
authorPeter Marko <peter.marko@siemens.com>
Tue, 11 Jul 2023 06:36:28 +0000 (08:36 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 13 Jul 2023 06:55:16 +0000 (07:55 +0100)
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.

Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/meta/cve-update-nvd2-native.bb

index c85df23f5988e5de16c9abd20e2368b4372c1bd5..e2584d21b3d32f543d63fcc73824b5f97256a165 100644 (file)
@@ -119,6 +119,7 @@ def nvd_request_next(url, api_key, args):
     import urllib.parse
     import gzip
     import http
+    import time
 
     headers = {}
     if api_key:
@@ -140,13 +141,9 @@ def nvd_request_next(url, api_key, args):
 
             r.close()
 
-        except UnicodeDecodeError:
-            # Received garbage, retry
-            bb.debug(2, "CVE database: received malformed data, retrying (request: %s)" %(full_request))
-            pass
-        except http.client.IncompleteRead:
-            # Read incomplete, let's try again
-            bb.debug(2, "CVE database: received incomplete data, retrying (request: %s)" %(full_request))
+        except Exception as e:
+            bb.debug(2, "CVE database: received error (%s), retrying (request: %s)" %(e, full_request))
+            time.sleep(6)
             pass
         else:
             return raw_data