osc copypac from project:systemsmanagement:saltstack:testing package:salt revision:377
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=181
This commit is contained in:
parent
55bbae899d
commit
dcf656e899
@ -1 +1 @@
|
||||
2a8598ff24165b69d93090c72aeedb6bf5e1c00f
|
||||
20d9e2d4f25a30971e2b5294d0f8124ab1205788
|
107
add-patch-support-for-allow-vendor-change-option-wit.patch
Normal file
107
add-patch-support-for-allow-vendor-change-option-wit.patch
Normal file
@ -0,0 +1,107 @@
|
||||
From cee4cc182b4740c912861c712dea7bc44eb70ffb Mon Sep 17 00:00:00 2001
|
||||
From: Martin Seidl <mseidl@suse.de>
|
||||
Date: Mon, 7 Dec 2020 01:10:51 +0100
|
||||
Subject: [PATCH] add patch support for allow vendor change option with
|
||||
zypper
|
||||
|
||||
---
|
||||
salt/modules/zypperpkg.py | 46 +++++++++++++++++++++++++++------------
|
||||
1 file changed, 32 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/salt/modules/zypperpkg.py b/salt/modules/zypperpkg.py
|
||||
index 6f22994bf0..4a5cb85e7c 100644
|
||||
--- a/salt/modules/zypperpkg.py
|
||||
+++ b/salt/modules/zypperpkg.py
|
||||
@@ -35,7 +35,6 @@ import salt.utils.versions
|
||||
from salt.exceptions import CommandExecutionError, MinionError, SaltInvocationError
|
||||
|
||||
# pylint: disable=import-error,redefined-builtin,no-name-in-module
|
||||
-from salt.ext import six
|
||||
from salt.ext.six.moves import configparser
|
||||
from salt.ext.six.moves.urllib.parse import urlparse as _urlparse
|
||||
from salt.utils.versions import LooseVersion
|
||||
@@ -1431,6 +1430,7 @@ def install(
|
||||
no_recommends=False,
|
||||
root=None,
|
||||
inclusion_detection=False,
|
||||
+ novendorchange=True,
|
||||
**kwargs
|
||||
):
|
||||
"""
|
||||
@@ -1478,6 +1478,10 @@ def install(
|
||||
skip_verify
|
||||
Skip the GPG verification check (e.g., ``--no-gpg-checks``)
|
||||
|
||||
+
|
||||
+ novendorchange
|
||||
+ Disallow vendor change
|
||||
+
|
||||
version
|
||||
Can be either a version number, or the combination of a comparison
|
||||
operator (<, >, <=, >=, =) and a version number (ex. '>1.2.3-4').
|
||||
@@ -1638,6 +1642,22 @@ def install(
|
||||
cmd_install.append(
|
||||
kwargs.get("resolve_capabilities") and "--capability" or "--name"
|
||||
)
|
||||
+ if novendorchange:
|
||||
+ if __grains__["osrelease_info"][0] > 11:
|
||||
+ cmd_install.append("--no-allow-vendor-change")
|
||||
+ log.info("Disabling vendor changes")
|
||||
+ else:
|
||||
+ log.warning(
|
||||
+ "Enabling/Disabling vendor changes is not supported on this Zypper version"
|
||||
+ )
|
||||
+ else:
|
||||
+ if __grains__["osrelease_info"][0] > 11:
|
||||
+ cmd_install.append("--allow-vendor-change")
|
||||
+ log.info("Enabling vendor changes")
|
||||
+ else:
|
||||
+ log.warning(
|
||||
+ "Enabling/Disabling vendor changes is not supported on this Zypper version"
|
||||
+ )
|
||||
|
||||
if not refresh:
|
||||
cmd_install.insert(0, "--no-refresh")
|
||||
@@ -1649,7 +1669,6 @@ def install(
|
||||
cmd_install.extend(fromrepoopt)
|
||||
if no_recommends:
|
||||
cmd_install.append("--no-recommends")
|
||||
-
|
||||
errors = []
|
||||
|
||||
# Split the targets into batches of 500 packages each, so that
|
||||
@@ -1793,19 +1812,18 @@ def upgrade(
|
||||
cmd_update.extend(["--from" if dist_upgrade else "--repo", repo])
|
||||
log.info("Targeting repos: %s", fromrepo)
|
||||
|
||||
- if dist_upgrade:
|
||||
- # TODO: Grains validation should be moved to Zypper class
|
||||
- if __grains__["osrelease_info"][0] > 11:
|
||||
- if novendorchange:
|
||||
- cmd_update.append("--no-allow-vendor-change")
|
||||
- log.info("Disabling vendor changes")
|
||||
- else:
|
||||
- cmd_update.append("--allow-vendor-change")
|
||||
- log.info("Enabling vendor changes")
|
||||
+ # TODO: Grains validation should be moved to Zypper class
|
||||
+ if __grains__["osrelease_info"][0] > 11:
|
||||
+ if novendorchange:
|
||||
+ cmd_update.append("--no-allow-vendor-change")
|
||||
+ log.info("Disabling vendor changes")
|
||||
else:
|
||||
- log.warning(
|
||||
- "Enabling/Disabling vendor changes is not supported on this Zypper version"
|
||||
- )
|
||||
+ cmd_update.append("--allow-vendor-change")
|
||||
+ log.info("Enabling vendor changes")
|
||||
+ else:
|
||||
+ log.warning(
|
||||
+ "Enabling/Disabling vendor changes is not supported on this Zypper version"
|
||||
+ )
|
||||
|
||||
if no_recommends:
|
||||
cmd_update.append("--no-recommends")
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
404
add-pkg.services_need_restart-302.patch
Normal file
404
add-pkg.services_need_restart-302.patch
Normal file
@ -0,0 +1,404 @@
|
||||
From c79f4a8619ff1275b2ec4400c1fb27d24c22a7eb Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Graul <mail@agraul.de>
|
||||
Date: Tue, 8 Dec 2020 15:35:49 +0100
|
||||
Subject: [PATCH] Add pkg.services_need_restart (#302)
|
||||
|
||||
* Add utils.systemd.pid_to_service function
|
||||
|
||||
This function translates a given PID to the systemd service name in case
|
||||
the process belongs to a running service. It uses DBUS for the
|
||||
translation if DBUS is available, falling back to parsing
|
||||
``systemctl status -o json'' output.
|
||||
|
||||
* Add zypperpkg.services_need_restart
|
||||
|
||||
pkg.services_need_restart returns a list of system services that were
|
||||
affected by package manager operations such as updates, downgrades or
|
||||
reinstallations without having been restarted. This might cause issues,
|
||||
e.g. in the case a shared object was loaded by a process and then
|
||||
replaced by the package manager.
|
||||
|
||||
(cherry picked from commit b950fcdbd6cc8cb08e1413a0ed05e0ae21717cea)
|
||||
|
||||
* Add aptpkg.services_need_restart
|
||||
|
||||
pkg.services_need_restart returns a list of system services that were
|
||||
affected by package manager operations such as updates, downgrades or
|
||||
reinstallations without having been restarted. This might cause issues,
|
||||
e.g. in the case a shared object was loaded by a process and then
|
||||
replaced by the package manager.
|
||||
|
||||
Requires checkrestart, which is part of the debian-goodies package and
|
||||
available from official Ubuntu and Debian repositories.
|
||||
|
||||
(cherry picked from commit b981f6ecb1a551b98c5cebab4975fc09c6a55a22)
|
||||
|
||||
* Add yumpkg.services_need_restart
|
||||
|
||||
pkg.services_need_restart returns a list of system services that were
|
||||
affected by package manager operations such as updates, downgrades or
|
||||
reinstallations without having been restarted. This might cause issues,
|
||||
e.g. in the case a shared object was loaded by a process and then
|
||||
replaced by the package manager.
|
||||
|
||||
Requires dnf with the needs-restarting plugin, which is part of
|
||||
dnf-plugins-core and installed by default on RHEL/CentOS/Fedora.
|
||||
Also requires systemd for the mapping between PIDs and systemd services.
|
||||
|
||||
(cherry picked from commit 5e2be1095729c9f73394e852b82749950957e6fb)
|
||||
|
||||
* Add changelog entry for issue #58261
|
||||
|
||||
(cherry picked from commit 148877ed8ff7a47132c1186274739e648f7acf1c)
|
||||
|
||||
* Simplify dnf needs-restarting output parsing
|
||||
|
||||
Co-authored-by: Wayne Werner <waynejwerner@gmail.com>
|
||||
(cherry picked from commit beb5d60f3cc64b880ec25ca188f8a73f6ec493dd)
|
||||
---
|
||||
changelog/58261.added | 1 +
|
||||
salt/modules/aptpkg.py | 42 ++++++++++++++++-
|
||||
salt/modules/yumpkg.py | 36 +++++++++++++++
|
||||
salt/modules/zypperpkg.py | 25 ++++++++++
|
||||
salt/utils/systemd.py | 69 ++++++++++++++++++++++++++++
|
||||
tests/unit/modules/test_aptpkg.py | 22 ++++++++-
|
||||
tests/unit/modules/test_yumpkg.py | 32 ++++++++++++-
|
||||
tests/unit/modules/test_zypperpkg.py | 14 ++++++
|
||||
8 files changed, 238 insertions(+), 3 deletions(-)
|
||||
create mode 100644 changelog/58261.added
|
||||
|
||||
diff --git a/changelog/58261.added b/changelog/58261.added
|
||||
new file mode 100644
|
||||
index 0000000000..537a43e80d
|
||||
--- /dev/null
|
||||
+++ b/changelog/58261.added
|
||||
@@ -0,0 +1 @@
|
||||
+Added ``pkg.services_need_restart`` which lists system services that should be restarted after package management operations.
|
||||
diff --git a/salt/modules/aptpkg.py b/salt/modules/aptpkg.py
|
||||
index 03e99af733..a0e0cc30c1 100644
|
||||
--- a/salt/modules/aptpkg.py
|
||||
+++ b/salt/modules/aptpkg.py
|
||||
@@ -38,7 +38,12 @@ import salt.utils.stringutils
|
||||
import salt.utils.systemd
|
||||
import salt.utils.versions
|
||||
import salt.utils.yaml
|
||||
-from salt.exceptions import CommandExecutionError, MinionError, SaltInvocationError
|
||||
+from salt.exceptions import (
|
||||
+ CommandExecutionError,
|
||||
+ CommandNotFoundError,
|
||||
+ MinionError,
|
||||
+ SaltInvocationError,
|
||||
+)
|
||||
from salt.modules.cmdmod import _parse_env
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -3029,3 +3034,38 @@ def list_downloaded(root=None, **kwargs):
|
||||
).isoformat(),
|
||||
}
|
||||
return ret
|
||||
+
|
||||
+
|
||||
+def services_need_restart(**kwargs):
|
||||
+ """
|
||||
+ .. versionadded:: NEXT
|
||||
+
|
||||
+ List services that use files which have been changed by the
|
||||
+ package manager. It might be needed to restart them.
|
||||
+
|
||||
+ Requires checkrestart from the debian-goodies package.
|
||||
+
|
||||
+ CLI Examples:
|
||||
+
|
||||
+ .. code-block:: bash
|
||||
+
|
||||
+ salt '*' pkg.services_need_restart
|
||||
+ """
|
||||
+ if not salt.utils.path.which_bin(["checkrestart"]):
|
||||
+ raise CommandNotFoundError(
|
||||
+ "'checkrestart' is needed. It is part of the 'debian-goodies' "
|
||||
+ "package which can be installed from official repositories."
|
||||
+ )
|
||||
+
|
||||
+ cmd = ["checkrestart", "--machine"]
|
||||
+ services = set()
|
||||
+
|
||||
+ cr_output = __salt__["cmd.run_stdout"](cmd, python_shell=False)
|
||||
+ for line in cr_output.split("\n"):
|
||||
+ if not line.startswith("SERVICE:"):
|
||||
+ continue
|
||||
+ end_of_name = line.find(",")
|
||||
+ service = line[8:end_of_name] # skip "SERVICE:"
|
||||
+ services.add(service)
|
||||
+
|
||||
+ return list(services)
|
||||
diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py
|
||||
index dd843f985b..df174e737d 100644
|
||||
--- a/salt/modules/yumpkg.py
|
||||
+++ b/salt/modules/yumpkg.py
|
||||
@@ -3434,3 +3434,39 @@ def del_repo_key(keyid, root=None, **kwargs):
|
||||
|
||||
"""
|
||||
return __salt__["lowpkg.remove_gpg_key"](keyid, root)
|
||||
+
|
||||
+
|
||||
+def services_need_restart(**kwargs):
|
||||
+ """
|
||||
+ .. versionadded:: NEXT
|
||||
+
|
||||
+ List services that use files which have been changed by the
|
||||
+ package manager. It might be needed to restart them.
|
||||
+
|
||||
+ Requires systemd.
|
||||
+
|
||||
+ CLI Examples:
|
||||
+
|
||||
+ .. code-block:: bash
|
||||
+
|
||||
+ salt '*' pkg.services_need_restart
|
||||
+ """
|
||||
+ if _yum() != "dnf":
|
||||
+ raise CommandExecutionError("dnf is required to list outdated services.")
|
||||
+ if not salt.utils.systemd.booted(__context__):
|
||||
+ raise CommandExecutionError("systemd is required to list outdated services.")
|
||||
+
|
||||
+ cmd = ["dnf", "--quiet", "needs-restarting"]
|
||||
+ dnf_output = __salt__["cmd.run_stdout"](cmd, python_shell=False)
|
||||
+ if not dnf_output:
|
||||
+ return []
|
||||
+
|
||||
+ services = set()
|
||||
+ for line in dnf_output.split("\n"):
|
||||
+ pid, has_delim, _ = line.partition(":")
|
||||
+ if has_delim:
|
||||
+ service = salt.utils.systemd.pid_to_service(pid.strip())
|
||||
+ if service:
|
||||
+ services.add(service)
|
||||
+
|
||||
+ return list(services)
|
||||
diff --git a/salt/modules/zypperpkg.py b/salt/modules/zypperpkg.py
|
||||
index 5e13c68708..6f22994bf0 100644
|
||||
--- a/salt/modules/zypperpkg.py
|
||||
+++ b/salt/modules/zypperpkg.py
|
||||
@@ -3092,3 +3092,28 @@ def del_repo_key(keyid, root=None, **kwargs):
|
||||
|
||||
"""
|
||||
return __salt__["lowpkg.remove_gpg_key"](keyid, root)
|
||||
+
|
||||
+
|
||||
+def services_need_restart(root=None, **kwargs):
|
||||
+ """
|
||||
+ .. versionadded:: NEXT
|
||||
+
|
||||
+ List services that use files which have been changed by the
|
||||
+ package manager. It might be needed to restart them.
|
||||
+
|
||||
+ root
|
||||
+ operate on a different root directory.
|
||||
+
|
||||
+ CLI Examples:
|
||||
+
|
||||
+ .. code-block:: bash
|
||||
+
|
||||
+ salt '*' pkg.services_need_restart
|
||||
+
|
||||
+ """
|
||||
+ cmd = ["ps", "-sss"]
|
||||
+
|
||||
+ zypper_output = __zypper__(root=root).nolock.call(*cmd)
|
||||
+ services = zypper_output.split()
|
||||
+
|
||||
+ return services
|
||||
diff --git a/salt/utils/systemd.py b/salt/utils/systemd.py
|
||||
index 4d902bc920..f42d0421f8 100644
|
||||
--- a/salt/utils/systemd.py
|
||||
+++ b/salt/utils/systemd.py
|
||||
@@ -11,6 +11,12 @@ import salt.utils.path
|
||||
import salt.utils.stringutils
|
||||
from salt.exceptions import SaltInvocationError
|
||||
|
||||
+try:
|
||||
+ import dbus
|
||||
+except ImportError:
|
||||
+ dbus = None
|
||||
+
|
||||
+
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -114,3 +120,66 @@ def has_scope(context=None):
|
||||
if _sd_version is None:
|
||||
return False
|
||||
return _sd_version >= 205
|
||||
+
|
||||
+
|
||||
+def pid_to_service(pid):
|
||||
+ """
|
||||
+ Check if a PID belongs to a systemd service and return its name.
|
||||
+ Return None if the PID does not belong to a service.
|
||||
+
|
||||
+ Uses DBUS if available.
|
||||
+ """
|
||||
+ if dbus:
|
||||
+ return _pid_to_service_dbus(pid)
|
||||
+ else:
|
||||
+ return _pid_to_service_systemctl(pid)
|
||||
+
|
||||
+
|
||||
+def _pid_to_service_systemctl(pid):
|
||||
+ systemd_cmd = ["systemctl", "--output", "json", "status", str(pid)]
|
||||
+ try:
|
||||
+ systemd_output = subprocess.run(
|
||||
+ systemd_cmd, check=True, text=True, capture_output=True
|
||||
+ )
|
||||
+ status_json = salt.utils.json.find_json(systemd_output.stdout)
|
||||
+ except (ValueError, subprocess.CalledProcessError):
|
||||
+ return None
|
||||
+
|
||||
+ name = status_json.get("_SYSTEMD_UNIT")
|
||||
+ if name and name.endswith(".service"):
|
||||
+ return _strip_suffix(name)
|
||||
+ else:
|
||||
+ return None
|
||||
+
|
||||
+
|
||||
+def _pid_to_service_dbus(pid):
|
||||
+ """
|
||||
+ Use DBUS to check if a PID belongs to a running systemd service and return the service name if it does.
|
||||
+ """
|
||||
+ bus = dbus.SystemBus()
|
||||
+ systemd_object = bus.get_object(
|
||||
+ "org.freedesktop.systemd1", "/org/freedesktop/systemd1"
|
||||
+ )
|
||||
+ systemd = dbus.Interface(systemd_object, "org.freedesktop.systemd1.Manager")
|
||||
+ try:
|
||||
+ service_path = systemd.GetUnitByPID(pid)
|
||||
+ service_object = bus.get_object("org.freedesktop.systemd1", service_path)
|
||||
+ service_props = dbus.Interface(
|
||||
+ service_object, "org.freedesktop.DBus.Properties"
|
||||
+ )
|
||||
+ service_name = service_props.Get("org.freedesktop.systemd1.Unit", "Id")
|
||||
+ name = str(service_name)
|
||||
+
|
||||
+ if name and name.endswith(".service"):
|
||||
+ return _strip_suffix(name)
|
||||
+ else:
|
||||
+ return None
|
||||
+ except dbus.DBusException:
|
||||
+ return None
|
||||
+
|
||||
+
|
||||
+def _strip_suffix(service_name):
|
||||
+ """
|
||||
+ Strip ".service" suffix from a given service name.
|
||||
+ """
|
||||
+ return service_name[:-8]
|
||||
diff --git a/tests/unit/modules/test_aptpkg.py b/tests/unit/modules/test_aptpkg.py
|
||||
index eb3f9e2da7..1d4d2f7fdc 100644
|
||||
--- a/tests/unit/modules/test_aptpkg.py
|
||||
+++ b/tests/unit/modules/test_aptpkg.py
|
||||
@@ -13,7 +13,6 @@ import textwrap
|
||||
import pytest
|
||||
import salt.modules.aptpkg as aptpkg
|
||||
from salt.exceptions import CommandExecutionError, SaltInvocationError
|
||||
-from salt.ext import six
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.mock import MagicMock, Mock, call, patch
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
@@ -1001,3 +1000,24 @@ class AptUtilsTestCase(TestCase, LoaderModuleMockMixin):
|
||||
# We should attempt to call the cmd 5 times
|
||||
self.assertEqual(cmd_mock.call_count, 5)
|
||||
cmd_mock.has_calls(expected_calls)
|
||||
+
|
||||
+ @patch("salt.utils.path.which_bin", Mock(return_value="/usr/sbin/checkrestart"))
|
||||
+ def test_services_need_restart(self):
|
||||
+ """
|
||||
+ Test that checkrestart output is parsed correctly
|
||||
+ """
|
||||
+ cr_output = """
|
||||
+PROCESSES: 24
|
||||
+PROGRAMS: 17
|
||||
+PACKAGES: 8
|
||||
+SERVICE:rsyslog,385,/usr/sbin/rsyslogd
|
||||
+SERVICE:cups-daemon,390,/usr/sbin/cupsd
|
||||
+ """
|
||||
+
|
||||
+ with patch.dict(
|
||||
+ aptpkg.__salt__, {"cmd.run_stdout": Mock(return_value=cr_output)}
|
||||
+ ):
|
||||
+ assert sorted(aptpkg.services_need_restart()) == [
|
||||
+ "cups-daemon",
|
||||
+ "rsyslog",
|
||||
+ ]
|
||||
diff --git a/tests/unit/modules/test_yumpkg.py b/tests/unit/modules/test_yumpkg.py
|
||||
index e65a1f8b8b..b97e82d307 100644
|
||||
--- a/tests/unit/modules/test_yumpkg.py
|
||||
+++ b/tests/unit/modules/test_yumpkg.py
|
||||
@@ -7,7 +7,7 @@ import salt.modules.yumpkg as yumpkg
|
||||
import salt.utils.platform
|
||||
from salt.exceptions import CommandExecutionError, SaltInvocationError
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
-from tests.support.mock import MagicMock, Mock, mock_open, patch
|
||||
+from tests.support.mock import MagicMock, Mock, call, mock_open, patch
|
||||
from tests.support.unit import TestCase, skipIf
|
||||
|
||||
try:
|
||||
@@ -1745,3 +1745,33 @@ class YumUtilsTestCase(TestCase, LoaderModuleMockMixin):
|
||||
python_shell=True,
|
||||
username="Darth Vader",
|
||||
)
|
||||
+
|
||||
+ @skipIf(not salt.utils.systemd.booted(), "Requires systemd")
|
||||
+ @patch("salt.modules.yumpkg._yum", Mock(return_value="dnf"))
|
||||
+ def test_services_need_restart(self):
|
||||
+ """
|
||||
+ Test that dnf needs-restarting output is parsed and
|
||||
+ salt.utils.systemd.pid_to_service is called as expected.
|
||||
+ """
|
||||
+ expected = ["firewalld", "salt-minion"]
|
||||
+
|
||||
+ dnf_mock = Mock(
|
||||
+ return_value="123 : /usr/bin/firewalld\n456 : /usr/bin/salt-minion\n"
|
||||
+ )
|
||||
+ systemd_mock = Mock(side_effect=["firewalld", "salt-minion"])
|
||||
+ with patch.dict(yumpkg.__salt__, {"cmd.run_stdout": dnf_mock}), patch(
|
||||
+ "salt.utils.systemd.pid_to_service", systemd_mock
|
||||
+ ):
|
||||
+ assert sorted(yumpkg.services_need_restart()) == expected
|
||||
+ systemd_mock.assert_has_calls([call("123"), call("456")])
|
||||
+
|
||||
+ @patch("salt.modules.yumpkg._yum", Mock(return_value="dnf"))
|
||||
+ def test_services_need_restart_requires_systemd(self):
|
||||
+ """Test that yumpkg.services_need_restart raises an error if systemd is unavailable."""
|
||||
+ with patch("salt.utils.systemd.booted", Mock(return_value=False)):
|
||||
+ pytest.raises(CommandExecutionError, yumpkg.services_need_restart)
|
||||
+
|
||||
+ @patch("salt.modules.yumpkg._yum", Mock(return_value="yum"))
|
||||
+ def test_services_need_restart_requires_dnf(self):
|
||||
+ """Test that yumpkg.services_need_restart raises an error if DNF is unavailable."""
|
||||
+ pytest.raises(CommandExecutionError, yumpkg.services_need_restart)
|
||||
diff --git a/tests/unit/modules/test_zypperpkg.py b/tests/unit/modules/test_zypperpkg.py
|
||||
index 018c1ffbca..9c4a224c55 100644
|
||||
--- a/tests/unit/modules/test_zypperpkg.py
|
||||
+++ b/tests/unit/modules/test_zypperpkg.py
|
||||
@@ -2213,3 +2213,17 @@ pattern() = package-c"""
|
||||
with patch.dict(zypper.__salt__, salt_mock):
|
||||
self.assertTrue(zypper.del_repo_key(keyid="keyid", root="/mnt"))
|
||||
salt_mock["lowpkg.remove_gpg_key"].assert_called_once_with("keyid", "/mnt")
|
||||
+
|
||||
+ def test_services_need_restart(self):
|
||||
+ """
|
||||
+ Test that zypper ps is used correctly to list services that need to
|
||||
+ be restarted.
|
||||
+ """
|
||||
+ expected = ["salt-minion", "firewalld"]
|
||||
+ zypper_output = "salt-minion\nfirewalld"
|
||||
+ zypper_mock = Mock()
|
||||
+ zypper_mock(root=None).nolock.call = Mock(return_value=zypper_output)
|
||||
+
|
||||
+ with patch("salt.modules.zypperpkg.__zypper__", zypper_mock):
|
||||
+ assert zypper.services_need_restart() == expected
|
||||
+ zypper_mock(root=None).nolock.call.assert_called_with("ps", "-sss")
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
42
fix-aptpkg.normalize_name-when-package-arch-is-all.patch
Normal file
42
fix-aptpkg.normalize_name-when-package-arch-is-all.patch
Normal file
@ -0,0 +1,42 @@
|
||||
From 763d63b72b9a20f22555b665033899e10f091b60 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
|
||||
<psuarezhernandez@suse.com>
|
||||
Date: Mon, 11 Jan 2021 15:45:28 +0000
|
||||
Subject: [PATCH] Fix aptpkg.normalize_name when package arch is 'all'
|
||||
|
||||
Add test case of DEB package where arch is 'all'
|
||||
---
|
||||
salt/modules/aptpkg.py | 2 +-
|
||||
tests/unit/modules/test_aptpkg.py | 2 ++
|
||||
2 files changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/salt/modules/aptpkg.py b/salt/modules/aptpkg.py
|
||||
index e001d2f11c..03e99af733 100644
|
||||
--- a/salt/modules/aptpkg.py
|
||||
+++ b/salt/modules/aptpkg.py
|
||||
@@ -208,7 +208,7 @@ def normalize_name(name):
|
||||
pkgname = name
|
||||
pkgarch = __grains__["osarch"]
|
||||
|
||||
- return pkgname if pkgarch in (__grains__["osarch"], "any") else name
|
||||
+ return pkgname if pkgarch in (__grains__["osarch"], "all", "any") else name
|
||||
|
||||
|
||||
def parse_arch(name):
|
||||
diff --git a/tests/unit/modules/test_aptpkg.py b/tests/unit/modules/test_aptpkg.py
|
||||
index 51dfce29eb..eb3f9e2da7 100644
|
||||
--- a/tests/unit/modules/test_aptpkg.py
|
||||
+++ b/tests/unit/modules/test_aptpkg.py
|
||||
@@ -808,6 +808,8 @@ class AptPkgTestCase(TestCase, LoaderModuleMockMixin):
|
||||
assert result == "foo", result
|
||||
result = aptpkg.normalize_name("foo:any")
|
||||
assert result == "foo", result
|
||||
+ result = aptpkg.normalize_name("foo:all")
|
||||
+ assert result == "foo", result
|
||||
result = aptpkg.normalize_name("foo:i386")
|
||||
assert result == "foo:i386", result
|
||||
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
99
fix-salt.utils.stringutils.to_str-calls-to-make-it-w.patch
Normal file
99
fix-salt.utils.stringutils.to_str-calls-to-make-it-w.patch
Normal file
@ -0,0 +1,99 @@
|
||||
From 435d9fbee299b06e1c58cdc0574b6a1975841879 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Zhestkov <vzhestkov@suse.com>
|
||||
Date: Wed, 25 Nov 2020 15:09:41 +0300
|
||||
Subject: [PATCH] Fix salt.utils.stringutils.to_str calls to make it
|
||||
working with numeric uid/gid
|
||||
|
||||
---
|
||||
salt/modules/file.py | 16 ++++++++++------
|
||||
salt/states/file.py | 11 +++++++++--
|
||||
2 files changed, 19 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/salt/modules/file.py b/salt/modules/file.py
|
||||
index b830b390d3..b9744393d7 100644
|
||||
--- a/salt/modules/file.py
|
||||
+++ b/salt/modules/file.py
|
||||
@@ -4970,6 +4970,12 @@ def check_perms(
|
||||
is_dir = os.path.isdir(name)
|
||||
is_link = os.path.islink(name)
|
||||
|
||||
+ def __safe_to_str(s):
|
||||
+ try:
|
||||
+ return salt.utils.stringutils.to_str(s)
|
||||
+ except:
|
||||
+ return salt.utils.stringutils.to_str(str(s))
|
||||
+
|
||||
# user/group changes if needed, then check if it worked
|
||||
if user:
|
||||
if isinstance(user, int):
|
||||
@@ -4979,7 +4985,7 @@ def check_perms(
|
||||
and user_to_uid(user) != user_to_uid(perms["luser"])
|
||||
) or (
|
||||
not salt.utils.platform.is_windows()
|
||||
- and salt.utils.stringutils.to_str(user) != perms["luser"]
|
||||
+ and __safe_to_str(user) != perms["luser"]
|
||||
):
|
||||
perms["cuser"] = user
|
||||
|
||||
@@ -4991,7 +4997,7 @@ def check_perms(
|
||||
and group_to_gid(group) != group_to_gid(perms["lgroup"])
|
||||
) or (
|
||||
not salt.utils.platform.is_windows()
|
||||
- and salt.utils.stringutils.to_str(group) != perms["lgroup"]
|
||||
+ and __safe_to_str(group) != perms["lgroup"]
|
||||
):
|
||||
perms["cgroup"] = group
|
||||
|
||||
@@ -5023,8 +5029,7 @@ def check_perms(
|
||||
and user != ""
|
||||
) or (
|
||||
not salt.utils.platform.is_windows()
|
||||
- and salt.utils.stringutils.to_str(user)
|
||||
- != get_user(name, follow_symlinks=follow_symlinks)
|
||||
+ and __safe_to_str(user) != get_user(name, follow_symlinks=follow_symlinks)
|
||||
and user != ""
|
||||
):
|
||||
if __opts__["test"] is True:
|
||||
@@ -5045,8 +5050,7 @@ def check_perms(
|
||||
and group != ""
|
||||
) or (
|
||||
not salt.utils.platform.is_windows()
|
||||
- and salt.utils.stringutils.to_str(group)
|
||||
- != get_group(name, follow_symlinks=follow_symlinks)
|
||||
+ and __safe_to_str(group) != get_group(name, follow_symlinks=follow_symlinks)
|
||||
and group != ""
|
||||
):
|
||||
if __opts__["test"] is True:
|
||||
diff --git a/salt/states/file.py b/salt/states/file.py
|
||||
index 89c70eb454..fd8ffde757 100644
|
||||
--- a/salt/states/file.py
|
||||
+++ b/salt/states/file.py
|
||||
@@ -989,15 +989,22 @@ def _check_dir_meta(name, user, group, mode, follow_symlinks=False):
|
||||
if not stats:
|
||||
changes["directory"] = "new"
|
||||
return changes
|
||||
+
|
||||
+ def __safe_to_str(s):
|
||||
+ try:
|
||||
+ return salt.utils.stringutils.to_str(s)
|
||||
+ except:
|
||||
+ return salt.utils.stringutils.to_str(str(s))
|
||||
+
|
||||
if (
|
||||
user is not None
|
||||
- and salt.utils.stringutils.to_str(user) != stats["user"]
|
||||
+ and __safe_to_str(user) != stats["user"]
|
||||
and user != stats.get("uid")
|
||||
):
|
||||
changes["user"] = user
|
||||
if (
|
||||
group is not None
|
||||
- and salt.utils.stringutils.to_str(group) != stats["group"]
|
||||
+ and __safe_to_str(group) != stats["group"]
|
||||
and group != stats.get("gid")
|
||||
):
|
||||
changes["group"] = group
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
29
force-zyppnotify-to-prefer-packages.db-than-packages.patch
Normal file
29
force-zyppnotify-to-prefer-packages.db-than-packages.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 36b107fb5108fe4e52e9ef522765d6ada588c50d Mon Sep 17 00:00:00 2001
|
||||
From: Victor Zhestkov <vzhestkov@suse.com>
|
||||
Date: Wed, 9 Dec 2020 14:58:55 +0300
|
||||
Subject: [PATCH] Force zyppnotify to prefer Packages.db than Packages
|
||||
if it exists
|
||||
|
||||
---
|
||||
scripts/suse/zypper/plugins/commit/zyppnotify | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/scripts/suse/zypper/plugins/commit/zyppnotify b/scripts/suse/zypper/plugins/commit/zyppnotify
|
||||
index 51ac02254e..d6a1bef42b 100755
|
||||
--- a/scripts/suse/zypper/plugins/commit/zyppnotify
|
||||
+++ b/scripts/suse/zypper/plugins/commit/zyppnotify
|
||||
@@ -20,7 +20,9 @@ class DriftDetector(Plugin):
|
||||
def __init__(self):
|
||||
Plugin.__init__(self)
|
||||
self.ck_path = "/var/cache/salt/minion/rpmdb.cookie"
|
||||
- self.rpm_path = "/var/lib/rpm/Packages"
|
||||
+ self.rpm_path = "/var/lib/rpm/Packages.db"
|
||||
+ if not os.path.exists(self.rpm_path):
|
||||
+ self.rpm_path = "/var/lib/rpm/Packages"
|
||||
|
||||
def _get_mtime(self):
|
||||
"""
|
||||
--
|
||||
2.29.2
|
||||
|
||||
|
6515
open-suse-3002.2-bigvm-310.patch
Normal file
6515
open-suse-3002.2-bigvm-310.patch
Normal file
File diff suppressed because it is too large
Load Diff
8842
open-suse-3002.2-virt-network-311.patch
Normal file
8842
open-suse-3002.2-virt-network-311.patch
Normal file
File diff suppressed because it is too large
Load Diff
41
salt.changes
41
salt.changes
@ -1,3 +1,44 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 12 12:09:35 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- Force zyppnotify to prefer Packages.db than Packages if it exists
|
||||
- Allow vendor change option with zypper
|
||||
- Add pkg.services_need_restart
|
||||
- Fix for file.check_perms to work with numeric uid/gid
|
||||
|
||||
- Added:
|
||||
* force-zyppnotify-to-prefer-packages.db-than-packages.patch
|
||||
* fix-salt.utils.stringutils.to_str-calls-to-make-it-w.patch
|
||||
* add-patch-support-for-allow-vendor-change-option-wit.patch
|
||||
* add-pkg.services_need_restart-302.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 12 10:31:02 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- virt: more network support
|
||||
Add more network and PCI/USB host devices passthrough support
|
||||
to virt module and states
|
||||
|
||||
- Added:
|
||||
* open-suse-3002.2-virt-network-311.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 12 09:55:36 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- Bigvm backports
|
||||
virt consoles, CPU tuning and topology, and memory tuning.
|
||||
|
||||
- Added:
|
||||
* open-suse-3002.2-bigvm-310.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jan 11 16:11:22 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- Fix pkg states when DEB package has "all" arch
|
||||
|
||||
- Added:
|
||||
* fix-aptpkg.normalize_name-when-package-arch-is-all.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 5 12:49:42 UTC 2021 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
|
21
salt.spec
21
salt.spec
@ -330,6 +330,20 @@ Patch135: drop-wrong-virt-capabilities-code-after-rebasing-pat.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/commit/5ea2f10b15684dd417bad858642faafc92cd382
|
||||
# (revert https://github.com/saltstack/salt/pull/58655)
|
||||
Patch136: revert-fixing-a-use-case-when-multiple-inotify-beaco.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/59269
|
||||
Patch137: fix-aptpkg.normalize_name-when-package-arch-is-all.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/310
|
||||
Patch138: open-suse-3002.2-bigvm-310.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/59146
|
||||
Patch139: open-suse-3002.2-virt-network-311.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/298
|
||||
Patch140: fix-salt.utils.stringutils.to_str-calls-to-make-it-w.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/58262
|
||||
Patch141: add-pkg.services_need_restart-302.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/301
|
||||
Patch142: add-patch-support-for-allow-vendor-change-option-wit.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/304
|
||||
Patch143: force-zyppnotify-to-prefer-packages.db-than-packages.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: logrotate
|
||||
@ -865,6 +879,13 @@ cp %{S:5} ./.travis.yml
|
||||
%patch134 -p1
|
||||
%patch135 -p1
|
||||
%patch136 -p1
|
||||
%patch137 -p1
|
||||
%patch138 -p1
|
||||
%patch139 -p1
|
||||
%patch140 -p1
|
||||
%patch141 -p1
|
||||
%patch142 -p1
|
||||
%patch143 -p1
|
||||
|
||||
%build
|
||||
# Putting /usr/bin at the front of $PATH is needed for RHEL/RES 7. Without this
|
||||
|
Loading…
x
Reference in New Issue
Block a user