From af41e9f28f68f8ea20c78e06c1c9a315d44366b2 Mon Sep 17 00:00:00 2001 From: Jackie Huang Date: Wed, 13 May 2020 22:15:16 +0800 Subject: [PATCH] stx-update: fix exceptions when stx rpm group do not exist There is not any stx rpm group in the repo for stx patches for now, e.g. updates-controller-worker So add a patch to avoid expections when the pkggrp is None, and change the error to warning. Signed-off-by: Jackie Huang Signed-off-by: Babak Sarashki --- meta-stx-flock/stx-update/cgcs-patch.bb | 1 + ...ot-do-the-packages_iter-if-pkggrp-is.patch | 72 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 meta-stx-flock/stx-update/files/0007-patch_agent-do-not-do-the-packages_iter-if-pkggrp-is.patch diff --git a/meta-stx-flock/stx-update/cgcs-patch.bb b/meta-stx-flock/stx-update/cgcs-patch.bb index 93fcb24..f22103b 100644 --- a/meta-stx-flock/stx-update/cgcs-patch.bb +++ b/meta-stx-flock/stx-update/cgcs-patch.bb @@ -14,6 +14,7 @@ SRC_URI += "file://0001-Remove-use-of-rpmUtils.miscutils-from-cgcs-patch.patch;s file://0004-Address-python3-pylint-errors-and-warnings.patch;striplevel=3 \ file://0005-Clean-up-pylint-W1201-logging-not-lazy-in-cgcs-patch.patch;striplevel=3 \ file://0006-Migrate-patch-agent-to-use-DNF-for-swmgmt.patch;striplevel=3 \ + file://0007-patch_agent-do-not-do-the-packages_iter-if-pkggrp-is.patch;striplevel=3 \ " RDEPENDS_${PN}_append = " \ diff --git a/meta-stx-flock/stx-update/files/0007-patch_agent-do-not-do-the-packages_iter-if-pkggrp-is.patch b/meta-stx-flock/stx-update/files/0007-patch_agent-do-not-do-the-packages_iter-if-pkggrp-is.patch new file mode 100644 index 0000000..149e1e2 --- /dev/null +++ b/meta-stx-flock/stx-update/files/0007-patch_agent-do-not-do-the-packages_iter-if-pkggrp-is.patch @@ -0,0 +1,72 @@ +From 059984de897fe2c8c48811ceb76a0331f94b3557 Mon Sep 17 00:00:00 2001 +From: Jackie Huang +Date: Wed, 13 May 2020 22:10:01 +0800 +Subject: [PATCH] patch_agent: do not do the packages_iter if pkggrp is None + +Addn the handling of packages_iter to the else block to avoid: +AttributeError: 'NoneType' object has no attribute 'packages_iter' + +Signed-off-by: Jackie Huang +--- + cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py | 44 ++++++++++++------------- + 1 file changed, 22 insertions(+), 22 deletions(-) + +diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py +index d8bc375..489d484 100644 +--- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py ++++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py +@@ -490,29 +490,29 @@ class PatchAgent(PatchService): + break + + if pkggrp is None: +- LOG.error("Could not find software group: %s", grp_id) +- +- for pkg in pkggrp.packages_iter(): +- try: +- res = pkgs_installed.filter(name=pkg.name) +- if len(res) == 0: +- found_pkg = avail.filter(name=pkg.name) +- self.missing_pkgs_dnf.append(found_pkg[0]) +- self.missing_pkgs.append(found_pkg[0].name) ++ LOG.warning("Could not find software group: %s", grp_id) ++ else: ++ for pkg in pkggrp.packages_iter(): ++ try: ++ res = pkgs_installed.filter(name=pkg.name) ++ if len(res) == 0: ++ found_pkg = avail.filter(name=pkg.name) ++ self.missing_pkgs_dnf.append(found_pkg[0]) ++ self.missing_pkgs.append(found_pkg[0].name) ++ self.changes = True ++ except dnf.exceptions.PackageNotFoundError: ++ self.missing_pkgs_dnf.append(pkg) ++ self.missing_pkgs.append(pkg.name) + self.changes = True +- except dnf.exceptions.PackageNotFoundError: +- self.missing_pkgs_dnf.append(pkg) +- self.missing_pkgs.append(pkg.name) +- self.changes = True +- +- self.installed = self.pkgobjs_to_list(self.installed_dnf) +- self.to_install = self.pkgobjs_to_list(self.to_install_dnf + self.to_downgrade_dnf) +- +- LOG.info("Patch state query returns %s", self.changes) +- LOG.info("Installed: %s", self.installed) +- LOG.info("To install: %s", self.to_install) +- LOG.info("To remove: %s", self.to_remove) +- LOG.info("Missing: %s", self.missing_pkgs) ++ ++ self.installed = self.pkgobjs_to_list(self.installed_dnf) ++ self.to_install = self.pkgobjs_to_list(self.to_install_dnf + self.to_downgrade_dnf) ++ ++ LOG.info("Patch state query returns %s", self.changes) ++ LOG.info("Installed: %s", self.installed) ++ LOG.info("To install: %s", self.to_install) ++ LOG.info("To remove: %s", self.to_remove) ++ LOG.info("Missing: %s", self.missing_pkgs) + + return True + +-- +2.7.4 +