From c4c9cf5bfe81005649e82edbccdbb7316c7c625a Mon Sep 17 00:00:00 2001 From: rabbitali Date: Tue, 21 Nov 2023 09:53:54 +0800 Subject: [PATCH] update return log field of the cve fix func --- 0005-add-specific-error-information.patch | 82 +++++++++++++++++++ ...return-log-field-of-the-cve-fix-func.patch | 63 ++++++++++++++ aops-ceres.spec | 8 +- 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 0005-add-specific-error-information.patch create mode 100644 0006-update-return-log-field-of-the-cve-fix-func.patch diff --git a/0005-add-specific-error-information.patch b/0005-add-specific-error-information.patch new file mode 100644 index 0000000..05eb8c7 --- /dev/null +++ b/0005-add-specific-error-information.patch @@ -0,0 +1,82 @@ +From 5b0551698b60ea0c01ad9ee223f7009f230caa12 Mon Sep 17 00:00:00 2001 +From: wang-guangge +Date: Mon, 20 Nov 2023 20:51:57 +0800 +Subject: [PATCH] add specific error information + +--- + hotpatch/hotupgrade.py | 9 ++++++--- + hotpatch/upgrade_en.py | 8 +++++--- + 2 files changed, 11 insertions(+), 6 deletions(-) + +diff --git a/hotpatch/hotupgrade.py b/hotpatch/hotupgrade.py +index c508e07..5dfee0d 100644 +--- a/hotpatch/hotupgrade.py ++++ b/hotpatch/hotupgrade.py +@@ -12,17 +12,19 @@ + # ******************************************************************************/ + from __future__ import print_function + ++from time import sleep ++ + import dnf.base + import dnf.exceptions + import hawkey +-from time import sleep + from dnf.cli import commands + from dnf.cli.option_parser import OptionParser + from dnfpluginscore import _, logger +-from .upgrade_en import UpgradeEnhanceCommand ++ + from .hot_updateinfo import HotUpdateinfoCommand +-from .updateinfo_parse import HotpatchUpdateInfo + from .syscare import Syscare ++from .updateinfo_parse import HotpatchUpdateInfo ++from .upgrade_en import UpgradeEnhanceCommand + from .version import Versions + + EMPTY_TAG = "-" +@@ -184,6 +186,7 @@ class HotupgradeCommand(dnf.cli.Command): + output, status = self.syscare.apply(hp_subname) + if status: + logger.info(_('Apply hot patch failed: %s.'), hp_subname) ++ logger.info(_('%s'), output) + else: + logger.info(_('Apply hot patch succeed: %s.'), hp_subname) + return status +diff --git a/hotpatch/upgrade_en.py b/hotpatch/upgrade_en.py +index 266bcae..3053179 100644 +--- a/hotpatch/upgrade_en.py ++++ b/hotpatch/upgrade_en.py +@@ -10,13 +10,14 @@ + # PURPOSE. + # See the Mulan PSL v2 for more details. + # ******************************************************************************/ +-import dnf + import gzip + import subprocess +-from dnfpluginscore import _ ++ ++import dnf + from dnf.cli import commands + from dnf.cli.commands.upgrade import UpgradeCommand + from dnf.cli.option_parser import OptionParser ++from dnfpluginscore import _, logger + + SUCCEED = 0 + FAIL = 255 +@@ -111,10 +112,11 @@ class UpgradeEnhanceCommand(dnf.cli.Command): + output, return_code = cmd_output(remove_cmd) + if return_code != SUCCEED: + print('Remove package failed: %s.' % pkg) ++ print(output) + exit(1) + else: + print('Remove package succeed: %s.' % pkg) +- # do not achieve the expected result of installing related kernel rpm ++ # do not achieve the expected result of installing related rpm + exit(1) + + def rebuild_rpm_db(self): +-- +2.27.0 + diff --git a/0006-update-return-log-field-of-the-cve-fix-func.patch b/0006-update-return-log-field-of-the-cve-fix-func.patch new file mode 100644 index 0000000..98e5187 --- /dev/null +++ b/0006-update-return-log-field-of-the-cve-fix-func.patch @@ -0,0 +1,63 @@ +From 27df2fbb6c18c382e7099015915f7efb673a9e06 Mon Sep 17 00:00:00 2001 +From: rabbitali +Date: Tue, 21 Nov 2023 09:02:09 +0800 +Subject: [PATCH] update return log field of the cve fix func + +--- + ceres/manages/vulnerability_manage.py | 22 ++++++++++++---------- + 1 file changed, 12 insertions(+), 10 deletions(-) + +diff --git a/ceres/manages/vulnerability_manage.py b/ceres/manages/vulnerability_manage.py +index da98297..23ae2ce 100644 +--- a/ceres/manages/vulnerability_manage.py ++++ b/ceres/manages/vulnerability_manage.py +@@ -621,11 +621,12 @@ class VulnerabilityManage: + a tuple containing two elements (update result, log). + """ + code, stdout, stderr = execute_shell_command(f"dnf upgrade-en {rpm_name} -y") ++ log = stdout + stderr + if code != CommandExitCode.SUCCEED: +- return TaskExecuteRes.FAIL, stderr +- if "Complete" not in stdout: +- return TaskExecuteRes.FAIL, stdout +- return TaskExecuteRes.SUCCEED, stdout ++ return TaskExecuteRes.FAIL, log ++ if "Complete" not in log: ++ return TaskExecuteRes.FAIL, log ++ return TaskExecuteRes.SUCCEED, log + + def _update_hotpatch_by_dnf_plugin(self, hotpatch_pkg: str) -> Tuple[str, str]: + """ +@@ -645,22 +646,23 @@ class VulnerabilityManage: + update_command = f"dnf hotupgrade {hotpatch_pkg} -y" + + code, stdout, stderr = execute_shell_command(update_command) ++ log = stdout + stderr + if code != CommandExitCode.SUCCEED: +- return TaskExecuteRes.FAIL, stderr ++ return TaskExecuteRes.FAIL, log + + if "Apply hot patch succeed" not in stdout and "No hot patches marked for install" not in stdout: +- return TaskExecuteRes.FAIL, stdout ++ return TaskExecuteRes.FAIL, log + + if not self.takeover and self.accepted: + try: + hotpatch_name = hotpatch_pkg.rsplit(".", 1)[0].split("-", 1)[1] +- _, log = self._set_hotpatch_status_by_dnf_plugin(hotpatch_name, "accept") +- stdout += f"\n\n{log}" ++ _, hotpatch_status_set_log = self._set_hotpatch_status_by_dnf_plugin(hotpatch_name, "accept") ++ log += f"\n\n{hotpatch_status_set_log}" + except IndexError as error: + LOGGER.error(error) +- stdout += f"\n\nhotpatch status set failed due to can't get correct hotpatch name!" ++ log += f"\n\nhotpatch status set failed due to can't get correct hotpatch name!" + +- return TaskExecuteRes.SUCCEED, stdout ++ return TaskExecuteRes.SUCCEED, log + + @staticmethod + def _set_hotpatch_status_by_dnf_plugin(hotpatch: str, operation: str) -> Tuple[bool, str]: +-- +2.33.0 + diff --git a/aops-ceres.spec b/aops-ceres.spec index 2264d9e..09916b5 100644 --- a/aops-ceres.spec +++ b/aops-ceres.spec @@ -2,7 +2,7 @@ Name: aops-ceres Version: v1.3.4 -Release: 7 +Release: 8 Summary: An agent which needs to be adopted in client, it managers some plugins, such as gala-gopher(kpi collection), fluentd(log collection) and so on. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} @@ -11,6 +11,8 @@ Patch0001: 0001-support-kabi-check.patch Patch0002: 0002-modify-re-of-kernel-filter.patch Patch0003: 0003-fix-bug-in-test_hotpatch.py.patch Patch0004: 0004-Modify-method-of-mark-invalid-data-and-add-summary.patch +Patch0005: 0005-add-specific-error-information.patch +Patch0006: 0006-update-return-log-field-of-the-cve-fix-func.patch BuildRequires: python3-setuptools Requires: python3-requests python3-jsonschema python3-libconf @@ -90,6 +92,10 @@ install -b -m755 ./extra-tools/da-tool/script/da-tool.sh ${RPM_BUILD_ROOT} %attr(755, root, root) %{_bindir}/da-tool-analysis %changelog +* Tue Nov 21 2023 wenxin - v1.3.4-8 +- update return log field of the cve fix func +- add specific error information + * Mon Nov 20 2023 liuchanggeng - v1.3.4-7 - new patch for da-tool - add summary report of schedswitch and delay