osc copypac from project:systemsmanagement:saltstack:testing package:salt revision:361
OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=175
This commit is contained in:
parent
d5f661c691
commit
fa16b8cedf
@ -1 +1 @@
|
||||
8afd80f388d6e97b882f8564a8afa1acab63e014
|
||||
3ce95a1b386927b6f8cb27d1a6421018bebccd9a
|
1272
backport-a-few-virt-prs-272.patch
Normal file
1272
backport-a-few-virt-prs-272.patch
Normal file
File diff suppressed because it is too large
Load Diff
112
bsc-1176024-fix-file-directory-user-and-group-owners.patch
Normal file
112
bsc-1176024-fix-file-directory-user-and-group-owners.patch
Normal file
@ -0,0 +1,112 @@
|
||||
From 8973063f6ad24fd5b3788292aa8cc341221d7fb5 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Zhestkov <35733135+vzhestkov@users.noreply.github.com>
|
||||
Date: Tue, 6 Oct 2020 12:36:41 +0300
|
||||
Subject: [PATCH] bsc#1176024: Fix file/directory user and group
|
||||
ownership containing UTF-8 characters (#275)
|
||||
|
||||
* Fix check_perm typos of file module
|
||||
|
||||
* Fix UTF8 support for user/group ownership operations with file module and state
|
||||
|
||||
* Fix UTF8 support for user/group ownership operations with file module and state
|
||||
|
||||
Co-authored-by: Victor Zhestkov <vzhestkov@vz-thinkpad.vzhestkov.net>
|
||||
---
|
||||
salt/modules/file.py | 18 +++++++++---------
|
||||
salt/states/file.py | 4 ++--
|
||||
2 files changed, 11 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/salt/modules/file.py b/salt/modules/file.py
|
||||
index b5b70e2d4c..0b516aff05 100644
|
||||
--- a/salt/modules/file.py
|
||||
+++ b/salt/modules/file.py
|
||||
@@ -256,7 +256,7 @@ def group_to_gid(group):
|
||||
try:
|
||||
if isinstance(group, int):
|
||||
return group
|
||||
- return grp.getgrnam(group).gr_gid
|
||||
+ return grp.getgrnam(salt.utils.stringutils.to_str(group)).gr_gid
|
||||
except KeyError:
|
||||
return ''
|
||||
|
||||
@@ -344,7 +344,7 @@ def user_to_uid(user):
|
||||
try:
|
||||
if isinstance(user, int):
|
||||
return user
|
||||
- return pwd.getpwnam(user).pw_uid
|
||||
+ return pwd.getpwnam(salt.utils.stringutils.to_str(user)).pw_uid
|
||||
except KeyError:
|
||||
return ''
|
||||
|
||||
@@ -4574,7 +4574,7 @@ def check_perms(name, ret, user, group, mode, attrs=None, follow_symlinks=False)
|
||||
if (salt.utils.platform.is_windows() and
|
||||
user_to_uid(user) != user_to_uid(perms['luser'])
|
||||
) or (
|
||||
- not salt.utils.platform.is_windows() and user != perms['luser']
|
||||
+ not salt.utils.platform.is_windows() and salt.utils.stringutils.to_str(user) != perms['luser']
|
||||
):
|
||||
perms['cuser'] = user
|
||||
|
||||
@@ -4584,7 +4584,7 @@ def check_perms(name, ret, user, group, mode, attrs=None, follow_symlinks=False)
|
||||
if (salt.utils.platform.is_windows() and
|
||||
group_to_gid(group) != group_to_gid(perms['lgroup'])
|
||||
) or (
|
||||
- not salt.utils.platform.is_windows() and group != perms['lgroup']
|
||||
+ not salt.utils.platform.is_windows() and salt.utils.stringutils.to_str(group) != perms['lgroup']
|
||||
):
|
||||
perms['cgroup'] = group
|
||||
|
||||
@@ -4615,7 +4615,7 @@ def check_perms(name, ret, user, group, mode, attrs=None, follow_symlinks=False)
|
||||
user != ''
|
||||
) or (
|
||||
not salt.utils.platform.is_windows() and
|
||||
- user != get_user(name, follow_symlinks=follow_symlinks) and
|
||||
+ salt.utils.stringutils.to_str(user) != get_user(name, follow_symlinks=follow_symlinks) and
|
||||
user != ''
|
||||
):
|
||||
if __opts__['test'] is True:
|
||||
@@ -4633,10 +4633,10 @@ def check_perms(name, ret, user, group, mode, attrs=None, follow_symlinks=False)
|
||||
if (salt.utils.platform.is_windows() and
|
||||
group_to_gid(group) != group_to_gid(
|
||||
get_group(name, follow_symlinks=follow_symlinks)) and
|
||||
- user != '') or (
|
||||
+ group != '') or (
|
||||
not salt.utils.platform.is_windows() and
|
||||
- group != get_group(name, follow_symlinks=follow_symlinks) and
|
||||
- user != ''
|
||||
+ salt.utils.stringutils.to_str(group) != get_group(name, follow_symlinks=follow_symlinks) and
|
||||
+ group != ''
|
||||
):
|
||||
if __opts__['test'] is True:
|
||||
ret['changes']['group'] = group
|
||||
@@ -4644,7 +4644,7 @@ def check_perms(name, ret, user, group, mode, attrs=None, follow_symlinks=False)
|
||||
ret['result'] = False
|
||||
ret['comment'].append('Failed to change group to {0}'
|
||||
.format(group))
|
||||
- elif 'cgroup' in perms and user != '':
|
||||
+ elif 'cgroup' in perms and group != '':
|
||||
ret['changes']['group'] = group
|
||||
|
||||
# Mode changes if needed
|
||||
diff --git a/salt/states/file.py b/salt/states/file.py
|
||||
index 0e925bb2ed..f21e0d12fc 100644
|
||||
--- a/salt/states/file.py
|
||||
+++ b/salt/states/file.py
|
||||
@@ -960,11 +960,11 @@ def _check_dir_meta(name,
|
||||
changes['directory'] = 'new'
|
||||
return changes
|
||||
if (user is not None
|
||||
- and user != stats['user']
|
||||
+ and salt.utils.stringutils.to_str(user) != stats['user']
|
||||
and user != stats.get('uid')):
|
||||
changes['user'] = user
|
||||
if (group is not None
|
||||
- and group != stats['group']
|
||||
+ and salt.utils.stringutils.to_str(group) != stats['group']
|
||||
and group != stats.get('gid')):
|
||||
changes['group'] = group
|
||||
# Normalize the dir mode
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
26
drop-wrong-mock-from-chroot-unit-test.patch
Normal file
26
drop-wrong-mock-from-chroot-unit-test.patch
Normal file
@ -0,0 +1,26 @@
|
||||
From e2c3b1cb72b796fe12f94af64baa2e64cbe5db0b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
|
||||
<psuarezhernandez@suse.com>
|
||||
Date: Tue, 13 Oct 2020 12:02:00 +0100
|
||||
Subject: [PATCH] Drop wrong mock from chroot unit test
|
||||
|
||||
---
|
||||
tests/unit/modules/test_chroot.py | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/tests/unit/modules/test_chroot.py b/tests/unit/modules/test_chroot.py
|
||||
index 62808ed680..045d56c5b0 100644
|
||||
--- a/tests/unit/modules/test_chroot.py
|
||||
+++ b/tests/unit/modules/test_chroot.py
|
||||
@@ -83,7 +83,6 @@ class ChrootTestCase(TestCase, LoaderModuleMockMixin):
|
||||
self.assertTrue(chroot.create('/chroot'))
|
||||
makedirs.assert_called()
|
||||
|
||||
- @patch("salt.modules.chroot.exist")
|
||||
@patch("salt.utils.files.fopen")
|
||||
def test_in_chroot(self, fopen):
|
||||
"""
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
51
ensure-virt.update-stop_on_reboot-is-updated-with-it.patch
Normal file
51
ensure-virt.update-stop_on_reboot-is-updated-with-it.patch
Normal file
@ -0,0 +1,51 @@
|
||||
From 173444cecc1e7b4867570f1f8764db1b7f82061e Mon Sep 17 00:00:00 2001
|
||||
From: Cedric Bosdonnat <cbosdonnat@suse.com>
|
||||
Date: Wed, 14 Oct 2020 12:39:16 +0200
|
||||
Subject: [PATCH] Ensure virt.update stop_on_reboot is updated with its
|
||||
default value (#280)
|
||||
|
||||
While all virt.update properties default values should not be used when
|
||||
updating the XML definition, the stop_on_reboot default value (False)
|
||||
needs to be passed still or the user will never be able to update with
|
||||
this value.
|
||||
---
|
||||
salt/modules/virt.py | 1 +
|
||||
tests/unit/modules/test_virt.py | 2 ++
|
||||
2 files changed, 3 insertions(+)
|
||||
|
||||
diff --git a/salt/modules/virt.py b/salt/modules/virt.py
|
||||
index 87ab7ca12d..9bc7bc6093 100644
|
||||
--- a/salt/modules/virt.py
|
||||
+++ b/salt/modules/virt.py
|
||||
@@ -2742,6 +2742,7 @@ def update(
|
||||
]
|
||||
|
||||
data = {k: v for k, v in six.iteritems(locals()) if bool(v)}
|
||||
+ data["stop_on_reboot"] = stop_on_reboot
|
||||
if boot_dev:
|
||||
data["boot_dev"] = {i + 1: dev for i, dev in enumerate(boot_dev.split())}
|
||||
need_update = salt.utils.xmlutil.change_xml(
|
||||
diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py
|
||||
index ca5e80d2d2..fbc03cf7a6 100644
|
||||
--- a/tests/unit/modules/test_virt.py
|
||||
+++ b/tests/unit/modules/test_virt.py
|
||||
@@ -1778,6 +1778,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
||||
<memory unit='KiB'>1048576</memory>
|
||||
<currentMemory unit='KiB'>1048576</currentMemory>
|
||||
<vcpu placement='auto'>1</vcpu>
|
||||
+ <on_reboot>restart</on_reboot>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc-i440fx-2.6'>hvm</type>
|
||||
<boot dev="hd"/>
|
||||
@@ -2350,6 +2351,7 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
||||
<memory unit='KiB'>1048576</memory>
|
||||
<currentMemory unit='KiB'>1048576</currentMemory>
|
||||
<vcpu placement='auto'>1</vcpu>
|
||||
+ <on_reboot>restart</on_reboot>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc-i440fx-2.6'>hvm</type>
|
||||
</os>
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
46
fix-grains.test_core-unit-test-277.patch
Normal file
46
fix-grains.test_core-unit-test-277.patch
Normal file
@ -0,0 +1,46 @@
|
||||
From 4998996a08db72a1b925b2c3f725c4fba4fe9622 Mon Sep 17 00:00:00 2001
|
||||
From: Dominik Gedon <dgedon@suse.de>
|
||||
Date: Tue, 6 Oct 2020 14:00:55 +0200
|
||||
Subject: [PATCH] Fix grains.test_core unit test (#277)
|
||||
|
||||
This reverts 63b94ae and fixes the grains test_core unit test. The
|
||||
changes are aligned with upstream.
|
||||
---
|
||||
tests/unit/grains/test_core.py | 13 ++++++++-----
|
||||
1 file changed, 8 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/tests/unit/grains/test_core.py b/tests/unit/grains/test_core.py
|
||||
index 36aa49f232..d3b6515d00 100644
|
||||
--- a/tests/unit/grains/test_core.py
|
||||
+++ b/tests/unit/grains/test_core.py
|
||||
@@ -69,10 +69,11 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
|
||||
def test_parse_etc_os_release(self, path_isfile_mock):
|
||||
path_isfile_mock.side_effect = lambda x: x == "/usr/lib/os-release"
|
||||
with salt.utils.files.fopen(os.path.join(OS_RELEASE_DIR, "ubuntu-17.10")) as os_release_file:
|
||||
- os_release_content = os_release_file.readlines()
|
||||
- with patch("salt.utils.files.fopen", mock_open()) as os_release_file:
|
||||
- os_release_file.return_value.__iter__.return_value = os_release_content
|
||||
- os_release = core._parse_os_release(["/etc/os-release", "/usr/lib/os-release"])
|
||||
+ os_release_content = os_release_file.read()
|
||||
+ with patch("salt.utils.files.fopen", mock_open(read_data=os_release_content)):
|
||||
+ os_release = core._parse_os_release(
|
||||
+ "/etc/os-release", "/usr/lib/os-release"
|
||||
+ )
|
||||
self.assertEqual(os_release, {
|
||||
"NAME": "Ubuntu",
|
||||
"VERSION": "17.10 (Artful Aardvark)",
|
||||
@@ -134,7 +135,9 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
|
||||
|
||||
def test_missing_os_release(self):
|
||||
with patch('salt.utils.files.fopen', mock_open(read_data={})):
|
||||
- os_release = core._parse_os_release(['/etc/os-release', '/usr/lib/os-release'])
|
||||
+ os_release = core._parse_os_release(
|
||||
+ "/etc/os-release", "/usr/lib/os-release"
|
||||
+ )
|
||||
self.assertEqual(os_release, {})
|
||||
|
||||
@skipIf(not salt.utils.platform.is_windows(), 'System is not Windows')
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
95
invalidate-file-list-cache-when-cache-file-modified-.patch
Normal file
95
invalidate-file-list-cache-when-cache-file-modified-.patch
Normal file
@ -0,0 +1,95 @@
|
||||
From 1ca1bb7c01b1e589147c32b16eda719537ab5b62 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
|
||||
<psuarezhernandez@suse.com>
|
||||
Date: Tue, 22 Sep 2020 15:15:51 +0100
|
||||
Subject: [PATCH] Invalidate file list cache when cache file modified
|
||||
time is in the future (bsc#1176397)
|
||||
|
||||
Add test_future_file_list_cache_file_ignored unit test
|
||||
---
|
||||
salt/fileserver/__init__.py | 2 +-
|
||||
tests/unit/test_fileserver.py | 47 +++++++++++++++++++++++++++++++++--
|
||||
2 files changed, 46 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/salt/fileserver/__init__.py b/salt/fileserver/__init__.py
|
||||
index 919987e2fc..1b8de51bdc 100644
|
||||
--- a/salt/fileserver/__init__.py
|
||||
+++ b/salt/fileserver/__init__.py
|
||||
@@ -142,7 +142,7 @@ def check_file_list_cache(opts, form, list_cache, w_lock):
|
||||
'file=%s mtime=%s current_time=%s',
|
||||
list_cache, current_time, file_mtime
|
||||
)
|
||||
- age = 0
|
||||
+ age = -1
|
||||
else:
|
||||
age = current_time - file_mtime
|
||||
else:
|
||||
diff --git a/tests/unit/test_fileserver.py b/tests/unit/test_fileserver.py
|
||||
index d38e22c8e1..b92b32947b 100644
|
||||
--- a/tests/unit/test_fileserver.py
|
||||
+++ b/tests/unit/test_fileserver.py
|
||||
@@ -6,11 +6,17 @@
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
-# Import Salt Testing libs
|
||||
-from tests.support.unit import TestCase
|
||||
+import datetime
|
||||
+import os
|
||||
+import time
|
||||
|
||||
+import salt.utils.files
|
||||
from salt import fileserver
|
||||
|
||||
+# Import Salt Testing libs
|
||||
+from tests.support.helpers import with_tempdir
|
||||
+from tests.support.unit import TestCase
|
||||
+
|
||||
|
||||
class MapDiffTestCase(TestCase):
|
||||
def test_diff_with_diffent_keys(self):
|
||||
@@ -28,3 +34,40 @@ class MapDiffTestCase(TestCase):
|
||||
map1 = {'file1': 12345}
|
||||
map2 = {'file1': 1234}
|
||||
assert fileserver.diff_mtime_map(map1, map2) is True
|
||||
+
|
||||
+
|
||||
+class VCSBackendWhitelistCase(TestCase):
|
||||
+ def setup_loader_modules(self):
|
||||
+ return {fileserver: {}}
|
||||
+
|
||||
+ @with_tempdir()
|
||||
+ def test_future_file_list_cache_file_ignored(self, cachedir):
|
||||
+ opts = {
|
||||
+ "fileserver_backend": ["roots"],
|
||||
+ "cachedir": cachedir,
|
||||
+ "extension_modules": "",
|
||||
+ }
|
||||
+
|
||||
+ back_cachedir = os.path.join(cachedir, "file_lists/roots")
|
||||
+ os.makedirs(os.path.join(back_cachedir))
|
||||
+
|
||||
+ # Touch a couple files
|
||||
+ for filename in ("base.p", "foo.txt"):
|
||||
+ with salt.utils.files.fopen(
|
||||
+ os.path.join(back_cachedir, filename), "wb"
|
||||
+ ) as _f:
|
||||
+ if filename == "base.p":
|
||||
+ _f.write(b"\x80")
|
||||
+
|
||||
+ # Set modification time to file list cache file to 1 year in the future
|
||||
+ now = datetime.datetime.utcnow()
|
||||
+ future = now + datetime.timedelta(days=365)
|
||||
+ mod_time = time.mktime(future.timetuple())
|
||||
+ os.utime(os.path.join(back_cachedir, "base.p"), (mod_time, mod_time))
|
||||
+
|
||||
+ list_cache = os.path.join(back_cachedir, "base.p")
|
||||
+ w_lock = os.path.join(back_cachedir, ".base.w")
|
||||
+ ret = fileserver.check_file_list_cache(opts, "files", list_cache, w_lock)
|
||||
+ assert (
|
||||
+ ret[1] is True
|
||||
+ ), "Cache file list cache file is not refreshed when future modification time"
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
58
salt.changes
58
salt.changes
@ -1,3 +1,61 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 14 10:49:33 UTC 2020 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- Ensure virt.update stop_on_reboot is updated with its default value
|
||||
|
||||
- Added:
|
||||
* ensure-virt.update-stop_on_reboot-is-updated-with-it.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 13 15:26:05 UTC 2020 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- Do not break package building for systemd OSes
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 13 11:10:06 UTC 2020 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- Drop wrong mock from chroot unit test
|
||||
|
||||
- Added:
|
||||
* drop-wrong-mock-from-chroot-unit-test.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 7 12:19:05 UTC 2020 - Jochen Breuer <jbreuer@suse.de>
|
||||
|
||||
- Support systemd versions with dot (bsc#1176294)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 6 12:52:51 UTC 2020 - Jochen Breuer <jbreuer@suse.de>
|
||||
|
||||
- Fix for grains.test_core unit test
|
||||
- Fix file/directory user and group ownership containing UTF-8
|
||||
characters (bsc#1176024)
|
||||
- Several changes to virtualization:
|
||||
- - Fix virt update when cpu and memory are changed
|
||||
- - Memory Tuning GSoC
|
||||
- - Properly fix memory setting regression in virt.update
|
||||
- - Expose libvirt on_reboot in virt states
|
||||
- Support transactional systems (MicroOS)
|
||||
- zypperpkg module ignores retcode 104 for search() (bsc#1159670)
|
||||
- Xen disk fixes. No longer generates volumes for Xen disks, but the
|
||||
corresponding file or block disk (bsc#1175987)
|
||||
|
||||
- Added:
|
||||
* fix-grains.test_core-unit-test-277.patch
|
||||
* support-transactional-systems-microos-271.patch
|
||||
* backport-a-few-virt-prs-272.patch
|
||||
* xen-disk-fixes-264.patch
|
||||
* zypperpkg-ignore-retcode-104-for-search-bsc-1176697-.patch
|
||||
* bsc-1176024-fix-file-directory-user-and-group-owners.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 23 14:48:41 UTC 2020 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
- Invalidate file list cache when cache file modified time is in the future (bsc#1176397)
|
||||
|
||||
- Added:
|
||||
* invalidate-file-list-cache-when-cache-file-modified-.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 16 11:52:33 UTC 2020 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
|
||||
|
||||
|
31
salt.spec
31
salt.spec
@ -345,6 +345,24 @@ Patch129: fix-virt.update-with-cpu-defined-263.patch
|
||||
Patch130: remove-msgpack-1.0.0-requirement-in-the-installed-me.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/commit/bc20f38d0fa492af70321fef7fe2530937dfc86a
|
||||
Patch131: prevent-import-errors-when-running-test_btrfs-unit-t.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/58529
|
||||
Patch132: invalidate-file-list-cache-when-cache-file-modified-.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/58400
|
||||
Patch133: xen-disk-fixes-264.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/58552
|
||||
Patch134: zypperpkg-ignore-retcode-104-for-search-bsc-1176697-.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/58520
|
||||
Patch135: support-transactional-systems-microos-271.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/272
|
||||
Patch136: backport-a-few-virt-prs-272.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/275
|
||||
Patch137: bsc-1176024-fix-file-directory-user-and-group-owners.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/277
|
||||
Patch138: fix-grains.test_core-unit-test-277.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/commit/e2c3b1cb72b796fe12f94af64baa2e64cbe5db0b
|
||||
Patch139: drop-wrong-mock-from-chroot-unit-test.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/280
|
||||
Patch140: ensure-virt.update-stop_on_reboot-is-updated-with-it.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: logrotate
|
||||
@ -690,6 +708,7 @@ Requires: pmtools
|
||||
%endif
|
||||
%if %{with systemd}
|
||||
%{?systemd_requires}
|
||||
BuildRequires: systemd
|
||||
%else
|
||||
%if 0%{?suse_version}
|
||||
Requires(pre): %insserv_prereq
|
||||
@ -982,6 +1001,15 @@ cp %{S:5} ./.travis.yml
|
||||
%patch129 -p1
|
||||
%patch130 -p1
|
||||
%patch131 -p1
|
||||
%patch132 -p1
|
||||
%patch133 -p1
|
||||
%patch134 -p1
|
||||
%patch135 -p1
|
||||
%patch136 -p1
|
||||
%patch137 -p1
|
||||
%patch138 -p1
|
||||
%patch139 -p1
|
||||
%patch140 -p1
|
||||
|
||||
%build
|
||||
# Putting /usr/bin at the front of $PATH is needed for RHEL/RES 7. Without this
|
||||
@ -1357,7 +1385,8 @@ if [ $1 -eq 2 ] ; then
|
||||
true
|
||||
fi
|
||||
%if %{with systemd}
|
||||
if [ `rpm -q systemd --queryformat="%%{VERSION}"` -lt 228 ]; then
|
||||
systemd_ver=$(rpm -q systemd --queryformat="%%{VERSION}")
|
||||
if [ "${systemd_ver%%.*}" -lt 228 ]; then
|
||||
# On systemd < 228 the 'TasksTask' attribute is not available.
|
||||
# Removing TasksMax from salt-master.service on SLE12SP1 LTSS (bsc#985112)
|
||||
sed -i '/TasksMax=infinity/d' %{_unitdir}/salt-master.service
|
||||
|
3145
support-transactional-systems-microos-271.patch
Normal file
3145
support-transactional-systems-microos-271.patch
Normal file
File diff suppressed because it is too large
Load Diff
1120
xen-disk-fixes-264.patch
Normal file
1120
xen-disk-fixes-264.patch
Normal file
File diff suppressed because it is too large
Load Diff
285
zypperpkg-ignore-retcode-104-for-search-bsc-1176697-.patch
Normal file
285
zypperpkg-ignore-retcode-104-for-search-bsc-1176697-.patch
Normal file
@ -0,0 +1,285 @@
|
||||
From 76c38695fa663d55876902feda4a1c93211a1a9f Mon Sep 17 00:00:00 2001
|
||||
From: Alberto Planas <aplanas@suse.com>
|
||||
Date: Mon, 5 Oct 2020 16:24:16 +0200
|
||||
Subject: [PATCH] zypperpkg: ignore retcode 104 for search()
|
||||
(bsc#1176697) (#270)
|
||||
|
||||
---
|
||||
salt/modules/zypperpkg.py | 38 ++++++++++--
|
||||
tests/unit/modules/test_zypperpkg.py | 87 ++++++++++++++++++++++------
|
||||
2 files changed, 101 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/salt/modules/zypperpkg.py b/salt/modules/zypperpkg.py
|
||||
index 96c3eed851..ad11da4ad1 100644
|
||||
--- a/salt/modules/zypperpkg.py
|
||||
+++ b/salt/modules/zypperpkg.py
|
||||
@@ -98,6 +98,8 @@ class _Zypper(object):
|
||||
}
|
||||
|
||||
LOCK_EXIT_CODE = 7
|
||||
+ NOT_FOUND_EXIT_CODE = 104
|
||||
+
|
||||
XML_DIRECTIVES = ['-x', '--xmlout']
|
||||
# ZYPPER_LOCK is not affected by --root
|
||||
ZYPPER_LOCK = '/var/run/zypp.pid'
|
||||
@@ -128,6 +130,7 @@ class _Zypper(object):
|
||||
self.__no_raise = False
|
||||
self.__refresh = False
|
||||
self.__ignore_repo_failure = False
|
||||
+ self.__ignore_not_found = False
|
||||
self.__systemd_scope = False
|
||||
self.__root = None
|
||||
|
||||
@@ -147,6 +150,9 @@ class _Zypper(object):
|
||||
# Ignore exit code for 106 (repo is not available)
|
||||
if 'no_repo_failure' in kwargs:
|
||||
self.__ignore_repo_failure = kwargs['no_repo_failure']
|
||||
+ # Ignore exit code for 104 (package not found)
|
||||
+ if "ignore_not_found" in kwargs:
|
||||
+ self.__ignore_not_found = kwargs["ignore_not_found"]
|
||||
if 'systemd_scope' in kwargs:
|
||||
self.__systemd_scope = kwargs['systemd_scope']
|
||||
if 'root' in kwargs:
|
||||
@@ -296,6 +302,10 @@ class _Zypper(object):
|
||||
if self.__root:
|
||||
self.__cmd.extend(['--root', self.__root])
|
||||
|
||||
+ # Do not consider 104 as a retcode error
|
||||
+ if self.__ignore_not_found:
|
||||
+ kwargs["success_retcodes"] = [_Zypper.NOT_FOUND_EXIT_CODE]
|
||||
+
|
||||
self.__cmd.extend(args)
|
||||
kwargs['output_loglevel'] = 'trace'
|
||||
kwargs['python_shell'] = False
|
||||
@@ -405,7 +415,11 @@ class Wildcard(object):
|
||||
Get available versions of the package.
|
||||
:return:
|
||||
'''
|
||||
- solvables = self.zypper.nolock.xml.call('se', '-xv', self.name).getElementsByTagName('solvable')
|
||||
+ solvables = (
|
||||
+ self.zypper(ignore_not_found=True)
|
||||
+ .nolock.xml.call("se", "-v", self.name)
|
||||
+ .getElementsByTagName("solvable")
|
||||
+ )
|
||||
if not solvables:
|
||||
raise CommandExecutionError('No packages found matching \'{0}\''.format(self.name))
|
||||
|
||||
@@ -983,7 +997,11 @@ def list_repo_pkgs(*args, **kwargs):
|
||||
return False
|
||||
|
||||
root = kwargs.get('root') or None
|
||||
- for node in __zypper__(root=root).xml.call('se', '-s', *targets).getElementsByTagName('solvable'):
|
||||
+ for node in (
|
||||
+ __zypper__(root=root, ignore_not_found=True)
|
||||
+ .xml.call("se", "-s", *targets)
|
||||
+ .getElementsByTagName("solvable")
|
||||
+ ):
|
||||
pkginfo = dict(node.attributes.items())
|
||||
try:
|
||||
if pkginfo['kind'] != 'package':
|
||||
@@ -2261,7 +2279,9 @@ def owner(*paths, **kwargs):
|
||||
def _get_visible_patterns(root=None):
|
||||
'''Get all available patterns in the repo that are visible.'''
|
||||
patterns = {}
|
||||
- search_patterns = __zypper__(root=root).nolock.xml.call('se', '-t', 'pattern')
|
||||
+ search_patterns = __zypper__(root=root, ignore_not_found=True).nolock.xml.call(
|
||||
+ "se", "-t", "pattern"
|
||||
+ )
|
||||
for element in search_patterns.getElementsByTagName('solvable'):
|
||||
installed = element.getAttribute('status') == 'installed'
|
||||
patterns[element.getAttribute('name')] = {
|
||||
@@ -2455,7 +2475,11 @@ def search(criteria, refresh=False, **kwargs):
|
||||
cmd.append(ALLOWED_SEARCH_OPTIONS.get(opt))
|
||||
|
||||
cmd.append(criteria)
|
||||
- solvables = __zypper__(root=root).nolock.noraise.xml.call(*cmd).getElementsByTagName('solvable')
|
||||
+ solvables = (
|
||||
+ __zypper__(root=root, ignore_not_found=True)
|
||||
+ .nolock.noraise.xml.call(*cmd)
|
||||
+ .getElementsByTagName("solvable")
|
||||
+ )
|
||||
if not solvables:
|
||||
raise CommandExecutionError(
|
||||
'No packages found matching \'{0}\''.format(criteria)
|
||||
@@ -2690,7 +2714,11 @@ def _get_patches(installed_only=False, root=None):
|
||||
List all known patches in repos.
|
||||
'''
|
||||
patches = {}
|
||||
- for element in __zypper__(root=root).nolock.xml.call('se', '-t', 'patch').getElementsByTagName('solvable'):
|
||||
+ for element in (
|
||||
+ __zypper__(root=root, ignore_not_found=True)
|
||||
+ .nolock.xml.call("se", "-t", "patch")
|
||||
+ .getElementsByTagName("solvable")
|
||||
+ ):
|
||||
installed = element.getAttribute('status') == 'installed'
|
||||
if (installed_only and installed) or not installed_only:
|
||||
patches[element.getAttribute('name')] = {
|
||||
diff --git a/tests/unit/modules/test_zypperpkg.py b/tests/unit/modules/test_zypperpkg.py
|
||||
index 1fce3352c6..a3d20f66d5 100644
|
||||
--- a/tests/unit/modules/test_zypperpkg.py
|
||||
+++ b/tests/unit/modules/test_zypperpkg.py
|
||||
@@ -39,7 +39,10 @@ class ZyppCallMock(object):
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
# If the call is for a configuration modifier, we return self
|
||||
- if any(i in kwargs for i in ('no_repo_failure', 'systemd_scope', 'root')):
|
||||
+ if any(
|
||||
+ i in kwargs
|
||||
+ for i in ("no_repo_failure", "ignore_not_found", "systemd_scope", "root")
|
||||
+ ):
|
||||
return self
|
||||
return MagicMock(return_value=self.__return_value)()
|
||||
|
||||
@@ -1303,8 +1306,9 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
<solvable status="installed" name="libzypp" kind="package" edition="16.2.4-19.5" arch="x86_64" repository="(System Packages)"/>
|
||||
</solvable-list></search-result></stream>
|
||||
"""
|
||||
- _zpr = MagicMock()
|
||||
- _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc))
|
||||
+ __zpr = MagicMock()
|
||||
+ __zpr.nolock.xml.call.return_value = minidom.parseString(xmldoc)
|
||||
+ _zpr = MagicMock(return_value=__zpr)
|
||||
wcard = zypper.Wildcard(_zpr)
|
||||
wcard.name, wcard.version = 'libzypp', '*'
|
||||
assert wcard._get_scope_versions(wcard._get_available_versions()) == ['16.2.4-19.5', '16.3.2-25.1', '16.5.2-27.9.1']
|
||||
@@ -1322,8 +1326,9 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
</solvable-list></search-result></stream>
|
||||
"""
|
||||
|
||||
- _zpr = MagicMock()
|
||||
- _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc))
|
||||
+ __zpr = MagicMock()
|
||||
+ __zpr.nolock.xml.call.return_value = minidom.parseString(xmldoc)
|
||||
+ _zpr = MagicMock(return_value=__zpr)
|
||||
wcard = zypper.Wildcard(_zpr)
|
||||
wcard.name, wcard.version = 'libzypp', '16.2.*-2*'
|
||||
assert wcard._get_scope_versions(wcard._get_available_versions()) == ['16.2.5-25.1', '16.2.6-27.9.1']
|
||||
@@ -1341,8 +1346,9 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
</solvable-list></search-result></stream>
|
||||
"""
|
||||
|
||||
- _zpr = MagicMock()
|
||||
- _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc))
|
||||
+ __zpr = MagicMock()
|
||||
+ __zpr.nolock.xml.call.return_value = minidom.parseString(xmldoc)
|
||||
+ _zpr = MagicMock(return_value=__zpr)
|
||||
wcard = zypper.Wildcard(_zpr)
|
||||
wcard.name, wcard.version = 'libzypp', '16.2.5*'
|
||||
assert wcard._get_scope_versions(wcard._get_available_versions()) == ['16.2.5-25.1']
|
||||
@@ -1360,8 +1366,9 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
</solvable-list></search-result></stream>
|
||||
"""
|
||||
|
||||
- _zpr = MagicMock()
|
||||
- _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc))
|
||||
+ __zpr = MagicMock()
|
||||
+ __zpr.nolock.xml.call.return_value = minidom.parseString(xmldoc)
|
||||
+ _zpr = MagicMock(return_value=__zpr)
|
||||
wcard = zypper.Wildcard(_zpr)
|
||||
wcard.name, wcard.version = 'libzypp', '*.1'
|
||||
assert wcard._get_scope_versions(wcard._get_available_versions()) == ['16.2.5-25.1', '17.2.6-27.9.1']
|
||||
@@ -1379,8 +1386,9 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
<solvable status="other-version" name="libzypp" kind="package" edition="17.2.6-27.9.1" arch="x86_64" repository="foo"/>
|
||||
</solvable-list></search-result></stream>
|
||||
"""
|
||||
- _zpr = MagicMock()
|
||||
- _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc))
|
||||
+ __zpr = MagicMock()
|
||||
+ __zpr.nolock.xml.call.return_value = minidom.parseString(xmldoc)
|
||||
+ _zpr = MagicMock(return_value=__zpr)
|
||||
assert zypper.Wildcard(_zpr)('libzypp', '16.2.4*') == '16.2.4-19.5'
|
||||
assert zypper.Wildcard(_zpr)('libzypp', '16.2*') == '16.2.5-25.1'
|
||||
assert zypper.Wildcard(_zpr)('libzypp', '*6-*') == '17.2.6-27.9.1'
|
||||
@@ -1399,8 +1407,10 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
<solvable status="other-version" name="libzypp" kind="package" edition="17.2.6-27.9.1" arch="x86_64" repository="foo"/>
|
||||
</solvable-list></search-result></stream>
|
||||
"""
|
||||
- _zpr = MagicMock()
|
||||
- _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc))
|
||||
+ __zpr = MagicMock()
|
||||
+ __zpr.nolock.xml.call.return_value = minidom.parseString(xmldoc)
|
||||
+ _zpr = MagicMock(return_value=__zpr)
|
||||
+
|
||||
assert zypper.Wildcard(_zpr)('libzypp', None) is None
|
||||
|
||||
def test_wildcard_to_query_typecheck(self):
|
||||
@@ -1416,8 +1426,9 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
<solvable status="other-version" name="libzypp" kind="package" edition="17.2.6-27.9.1" arch="x86_64" repository="foo"/>
|
||||
</solvable-list></search-result></stream>
|
||||
"""
|
||||
- _zpr = MagicMock()
|
||||
- _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc))
|
||||
+ __zpr = MagicMock()
|
||||
+ __zpr.nolock.xml.call.return_value = minidom.parseString(xmldoc)
|
||||
+ _zpr = MagicMock(return_value=__zpr)
|
||||
assert isinstance(zypper.Wildcard(_zpr)('libzypp', '*.1'), six.string_types)
|
||||
|
||||
def test_wildcard_to_query_condition_preservation(self):
|
||||
@@ -1433,8 +1444,9 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
<solvable status="other-version" name="libzypp" kind="package" edition="17.2.6-27.9.1" arch="x86_64" repository="foo"/>
|
||||
</solvable-list></search-result></stream>
|
||||
"""
|
||||
- _zpr = MagicMock()
|
||||
- _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc))
|
||||
+ __zpr = MagicMock()
|
||||
+ __zpr.nolock.xml.call.return_value = minidom.parseString(xmldoc)
|
||||
+ _zpr = MagicMock(return_value=__zpr)
|
||||
|
||||
for op in zypper.Wildcard.Z_OP:
|
||||
assert zypper.Wildcard(_zpr)('libzypp', '{0}*.1'.format(op)) == '{0}17.2.6-27.9.1'.format(op)
|
||||
@@ -1456,8 +1468,10 @@ Repository 'DUMMY' not found by its alias, number, or URI.
|
||||
<solvable status="other-version" name="libzypp" kind="package" edition="17.2.6-27.9.1" arch="x86_64" repository="foo"/>
|
||||
</solvable-list></search-result></stream>
|
||||
"""
|
||||
- _zpr = MagicMock()
|
||||
- _zpr.nolock.xml.call = MagicMock(return_value=minidom.parseString(xmldoc))
|
||||
+ __zpr = MagicMock()
|
||||
+ __zpr.nolock.xml.call.return_value = minidom.parseString(xmldoc)
|
||||
+ _zpr = MagicMock(return_value=__zpr)
|
||||
+
|
||||
with self.assertRaises(CommandExecutionError):
|
||||
for op in ['>>', '==', '<<', '+']:
|
||||
zypper.Wildcard(_zpr)('libzypp', '{0}*.1'.format(op))
|
||||
@@ -1557,3 +1571,38 @@ pattern() = package-c"""
|
||||
with patch.dict(zypper.__context__, context):
|
||||
zypper._clean_cache()
|
||||
self.assertEqual(zypper.__context__, {'pkg.other_data': None})
|
||||
+
|
||||
+ def test_search(self):
|
||||
+ """Test zypperpkg.search()"""
|
||||
+ xml_mock = MagicMock(return_value=[])
|
||||
+ zypp_mock = MagicMock(return_value=xml_mock)
|
||||
+ ZyppCallMock(return_value=xml_mock)
|
||||
+ with patch("salt.modules.zypperpkg.__zypper__", zypp_mock):
|
||||
+ zypper.search("emacs")
|
||||
+ zypp_mock.assert_called_with(root=None, ignore_not_found=True)
|
||||
+ xml_mock.nolock.noraise.xml.call.assert_called_with("search", "emacs")
|
||||
+
|
||||
+ def test_search_not_found(self):
|
||||
+ """Test zypperpkg.search()"""
|
||||
+ ret = {
|
||||
+ "stdout": "<?xml version='1.0'?><stream></stream>",
|
||||
+ "stderr": None,
|
||||
+ "retcode": 104,
|
||||
+ }
|
||||
+ run_all_mock = MagicMock(return_value=ret)
|
||||
+ with patch.dict(zypper.__salt__, {"cmd.run_all": run_all_mock}):
|
||||
+ self.assertRaises(CommandExecutionError, zypper.search, "vim")
|
||||
+ run_all_mock.assert_called_with(
|
||||
+ [
|
||||
+ "zypper",
|
||||
+ "--non-interactive",
|
||||
+ "--xmlout",
|
||||
+ "--no-refresh",
|
||||
+ "search",
|
||||
+ "vim",
|
||||
+ ],
|
||||
+ success_retcodes=[104],
|
||||
+ output_loglevel="trace",
|
||||
+ python_shell=False,
|
||||
+ env={"ZYPP_READONLY_HACK": "1"},
|
||||
+ )
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user