From: Owen Synge Date: Fri, 26 Feb 2016 12:20:44 +0000 (-0500) Subject: [RM-16979] zypper handle ZYPPER_EXIT_INF_CAP_NOT_FOUND return code X-Git-Tag: v1.5.35~2^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6b8b2285c3aa6920664252099c3e90c85a72f18c;p=ceph-deploy.git [RM-16979] zypper handle ZYPPER_EXIT_INF_CAP_NOT_FOUND return code When removing package(s) with zypper, that are (all) installed zypper may succeed and return 0, but when any package(s) are not present before requesting them to be removed zypper will return 104 on success. The function remoto.process.run raises a "RuntimeError" exception when the command does not return 0 in the form: RuntimeError("Failed to execute command: %s" % " ".join(cmd)) Hence to maintain the expected behaviour, remoto.process.check is used, and the error code is checked, and if it does not match 0 or 104 the exception is raised. Signed-off-by: Owen Synge --- diff --git a/ceph_deploy/util/pkg_managers.py b/ceph_deploy/util/pkg_managers.py index 7d1ff28..a6a6794 100644 --- a/ceph_deploy/util/pkg_managers.py +++ b/ceph_deploy/util/pkg_managers.py @@ -306,7 +306,15 @@ class Zypper(PackageManager): extra_flags = [extra_flags] cmd.extend(extra_flags) cmd.extend(packages) - return self._run(cmd) + stdout, stderr, exitrc = remoto.process.check( + self.remote_conn, + cmd, + **kw + ) + # exitrc is 104 when package(s) not installed. + if not exitrc in [0, 104]: + raise RuntimeError("Failed to execute command: %s" % " ".join(cmd)) + return def clean(self): cmd = self.executable + ['refresh']