diff --git a/0004-Add-network-request-exception-capture.patch b/0004-Add-network-request-exception-capture.patch new file mode 100644 index 0000000000000000000000000000000000000000..d29316e4c3d35c725a87b39eeb21642987eb5dc5 --- /dev/null +++ b/0004-Add-network-request-exception-capture.patch @@ -0,0 +1,104 @@ +From 0152aabe5a422d18f7f63e53913191ebc4211a70 Mon Sep 17 00:00:00 2001 +From: young <954906362@qq.com> +Date: Wed, 10 May 2023 16:39:45 +0800 +Subject: [PATCH 1/2] Add network request exception capture +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + apollo/cron/download_sa_manager.py | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +diff --git a/apollo/cron/download_sa_manager.py b/apollo/cron/download_sa_manager.py +index a46ad5a..e9f89b3 100644 +--- a/apollo/cron/download_sa_manager.py ++++ b/apollo/cron/download_sa_manager.py +@@ -10,7 +10,7 @@ + # PURPOSE. + # See the Mulan PSL v2 for more details. + # ******************************************************************************/ +-from gevent import monkey; monkey.patch_all(thread=False) ++from gevent import monkey; monkey.patch_all() + import gevent + import datetime + import os +@@ -67,10 +67,11 @@ class TimedDownloadSATask(TimedTaskBase): + download_record, download_failed_advisory = proxy.get_advisory_download_record() + sa_name_list = TimedDownloadSATask.get_incremental_sa_name_list( + download_record) +- +- jobs = [gevent.spawn(TimedDownloadSATask.download_security_advisory, sa_name) +- for sa_name in sa_name_list] +- gevent.joinall(jobs) ++ # Limit the number of requests to 20 per time ++ for i in range(0, len(sa_name_list), 20): ++ jobs = [gevent.spawn(TimedDownloadSATask.download_security_advisory, sa_name) ++ for sa_name in sa_name_list[i: i + 20]] ++ gevent.joinall(jobs) + + TimedDownloadSATask.save_security_advisory_to_database(proxy) + +@@ -134,10 +135,13 @@ class TimedDownloadSATask(TimedTaskBase): + response body or "", "" means request failed + """ + try: +- response = urllib.request.urlopen(url, timeout=10) ++ response = urllib.request.urlopen(url, timeout=30) + return response.read() +- except urllib.error.HTTPError: +- LOGGER.info("Exception %s") ++ except urllib.error.HTTPError as e: ++ LOGGER.info("Exception HTTPError %s" % e) ++ return None ++ except urllib.error.URLError as e: ++ LOGGER.info("Exception URLError %s" % e) + return "" + + @staticmethod +-- +Gitee + + +From 8979cee0900fa64e05a06c68b6f0032c859cb904 Mon Sep 17 00:00:00 2001 +From: young <954906362@qq.com> +Date: Thu, 11 May 2023 11:37:10 +0800 +Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=BC=95=E5=85=A5monkey.?= + =?UTF-8?q?patch=5Fall=E7=9A=84=E4=BD=8D=E7=BD=AE=EF=BC=8C=E6=B6=88?= + =?UTF-8?q?=E9=99=A4=E8=AD=A6=E5=91=8A=E4=BF=A1=E6=81=AF?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + apollo/cron/download_sa_manager.py | 1 - + apollo/manage.py | 1 + + 2 files changed, 1 insertion(+), 1 deletion(-) + +diff --git a/apollo/cron/download_sa_manager.py b/apollo/cron/download_sa_manager.py +index e9f89b3..9fcadef 100644 +--- a/apollo/cron/download_sa_manager.py ++++ b/apollo/cron/download_sa_manager.py +@@ -10,7 +10,6 @@ + # PURPOSE. + # See the Mulan PSL v2 for more details. + # ******************************************************************************/ +-from gevent import monkey; monkey.patch_all() + import gevent + import datetime + import os +diff --git a/apollo/manage.py b/apollo/manage.py +index 5c13c70..7796fed 100644 +--- a/apollo/manage.py ++++ b/apollo/manage.py +@@ -15,6 +15,7 @@ Time: + Author: + Description: Manager that start aops-manager + """ ++from gevent import monkey; monkey.patch_all(thread=False) + import redis + import sqlalchemy + from flask import Flask +-- +Gitee + diff --git a/aops-apollo.spec b/aops-apollo.spec index 8be93c91a9630bdbcf00840e319e27a6652422df..dab63b14eb2541b8180761c8ef2603966215ec69 100644 --- a/aops-apollo.spec +++ b/aops-apollo.spec @@ -1,6 +1,6 @@ Name: aops-apollo Version: v1.2.0 -Release: 3 +Release: 4 Summary: Cve management service, monitor machine vulnerabilities and provide fix functions. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} @@ -8,6 +8,7 @@ Source0: %{name}-%{version}.tar.gz Patch0001: 0001-fix-args-not-effective-bug.patch Patch0002: 0002-download-SA-collaborative-process.patch Patch0003: 0003-fix-send-two-emails-bug.patch +Patch0004: 0004-Add-network-request-exception-capture.patch BuildRequires: python3-setuptools Requires: aops-vulcanus >= v1.2.0 @@ -23,7 +24,7 @@ Cve management service, monitor machine vulnerabilities and provide fix function %package -n dnf-hotpatch-plugin Summary: dnf hotpatch plugin -Requires: python3-hawkey python3-dnf syscare +Requires: python3-hawkey python3-dnf syscare >= 1.0.1 %description -n dnf-hotpatch-plugin dnf hotpatch plugin, it's about hotpatch query and fix @@ -55,9 +56,11 @@ cp -r hotpatch %{buildroot}/%{python3_sitelib}/dnf-plugins/ %{python3_sitelib}/dnf-plugins/* %changelog +* Thu May 11 2023 ptyang<1475324955@qq.com> - v1.2.0-4 +- Add network request exception capture + * Tue May 9 2023 ptyang<1475324955@qq.com> - v1.2.0-3 -- fix args not effective bug -- download SA using a collaborative process +- fix send two emails bug * Thu Apr 27 2023 ptyang<1475324955@qq.com> - v1.2.0-2 - fix args not effective bug