Accepting request 826691 from systemsmanagement:saltstack
- Require /usr/bin/python instead of /bin/python for RHEL-family (bsc#1173936) - Don't install SuSEfirewall2 service files in Factory - Fix __mount_device wrapper to accept separate args and kwargs - Added: * fix-__mount_device-wrapper-254.patch OBS-URL: https://build.opensuse.org/request/show/826691 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/salt?expand=0&rev=107
This commit is contained in:
commit
a8db5cbcd6
@ -1 +1 @@
|
||||
82be64a05e54109be6af70998d154fe62150ce9c
|
||||
3c85bd3a365dd15aae8f08c2cb95f16db987fe7b
|
91
fix-__mount_device-wrapper-254.patch
Normal file
91
fix-__mount_device-wrapper-254.patch
Normal file
@ -0,0 +1,91 @@
|
||||
From 7ad2d6067400f55dc7b70745216fab20620f35fd Mon Sep 17 00:00:00 2001
|
||||
From: Alberto Planas <aplanas@suse.com>
|
||||
Date: Wed, 29 Jul 2020 16:11:47 +0200
|
||||
Subject: [PATCH] Fix __mount_device wrapper (#254)
|
||||
|
||||
Some recent change in Salt is now doing the right thing, and calling the
|
||||
different states with separated args and kwargs. This change trigger a
|
||||
hidden bug in the __mount_device decorator, that expect those parameter
|
||||
to be in kwargs, as is happening during the test.
|
||||
|
||||
This patch change the way that the wrapper inside the decorator search
|
||||
for the name and device parameters, first looking into kwargs and later
|
||||
in args if possible. A new test is introduced to exercise both cases.
|
||||
|
||||
Fix #58012
|
||||
|
||||
(cherry picked from commit 2089645e2478751dc795127cfd14d0385c2e0899)
|
||||
---
|
||||
changelog/58012.fixed | 1 +
|
||||
salt/states/btrfs.py | 6 +++---
|
||||
tests/unit/states/test_btrfs.py | 27 +++++++++++++++++++++++++++
|
||||
3 files changed, 31 insertions(+), 3 deletions(-)
|
||||
create mode 100644 changelog/58012.fixed
|
||||
|
||||
diff --git a/changelog/58012.fixed b/changelog/58012.fixed
|
||||
new file mode 100644
|
||||
index 0000000000..13a1ef747d
|
||||
--- /dev/null
|
||||
+++ b/changelog/58012.fixed
|
||||
@@ -0,0 +1 @@
|
||||
+Fix btrfs state decorator, that produces exceptions when creating subvolumes.
|
||||
\ No newline at end of file
|
||||
diff --git a/salt/states/btrfs.py b/salt/states/btrfs.py
|
||||
index af78c8ae00..d0d6095c46 100644
|
||||
--- a/salt/states/btrfs.py
|
||||
+++ b/salt/states/btrfs.py
|
||||
@@ -103,9 +103,9 @@ def __mount_device(action):
|
||||
'''
|
||||
@functools.wraps(action)
|
||||
def wrapper(*args, **kwargs):
|
||||
- name = kwargs['name']
|
||||
- device = kwargs['device']
|
||||
- use_default = kwargs.get('use_default', False)
|
||||
+ name = kwargs.get("name", args[0] if args else None)
|
||||
+ device = kwargs.get("device", args[1] if len(args) > 1 else None)
|
||||
+ use_default = kwargs.get("use_default", False)
|
||||
|
||||
ret = {
|
||||
'name': name,
|
||||
diff --git a/tests/unit/states/test_btrfs.py b/tests/unit/states/test_btrfs.py
|
||||
index c68f6279dc..c722630aef 100644
|
||||
--- a/tests/unit/states/test_btrfs.py
|
||||
+++ b/tests/unit/states/test_btrfs.py
|
||||
@@ -245,6 +245,33 @@ class BtrfsTestCase(TestCase, LoaderModuleMockMixin):
|
||||
mount.assert_called_once()
|
||||
umount.assert_called_once()
|
||||
|
||||
+ @skipIf(salt.utils.platform.is_windows(), "Skip on Windows")
|
||||
+ @patch("salt.states.btrfs._umount")
|
||||
+ @patch("salt.states.btrfs._mount")
|
||||
+ def test_subvolume_created_exists_decorator(self, mount, umount):
|
||||
+ """
|
||||
+ Test creating a subvolume using a non-kwargs call
|
||||
+ """
|
||||
+ mount.return_value = "/tmp/xxx"
|
||||
+ salt_mock = {
|
||||
+ "btrfs.subvolume_exists": MagicMock(return_value=True),
|
||||
+ }
|
||||
+ opts_mock = {
|
||||
+ "test": False,
|
||||
+ }
|
||||
+ with patch.dict(btrfs.__salt__, salt_mock), patch.dict(
|
||||
+ btrfs.__opts__, opts_mock
|
||||
+ ):
|
||||
+ assert btrfs.subvolume_created("@/var", "/dev/sda1") == {
|
||||
+ "name": "@/var",
|
||||
+ "result": True,
|
||||
+ "changes": {},
|
||||
+ "comment": ["Subvolume @/var already present"],
|
||||
+ }
|
||||
+ salt_mock["btrfs.subvolume_exists"].assert_called_with("/tmp/xxx/@/var")
|
||||
+ mount.assert_called_once()
|
||||
+ umount.assert_called_once()
|
||||
+
|
||||
@patch('salt.states.btrfs._umount')
|
||||
@patch('salt.states.btrfs._mount')
|
||||
def test_subvolume_created_exists_test(self, mount, umount):
|
||||
--
|
||||
2.27.0
|
||||
|
||||
|
14
salt.changes
14
salt.changes
@ -1,3 +1,17 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Aug 10 15:15:31 UTC 2020 - Alexander Graul <alexander.graul@suse.com>
|
||||
|
||||
- Require /usr/bin/python instead of /bin/python for RHEL-family (bsc#1173936)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jul 31 14:55:06 UTC 2020 - Alexander Graul <alexander.graul@suse.com>
|
||||
|
||||
- Don't install SuSEfirewall2 service files in Factory
|
||||
- Fix __mount_device wrapper to accept separate args and kwargs
|
||||
|
||||
- Added:
|
||||
* fix-__mount_device-wrapper-254.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jul 3 13:19:02 UTC 2020 - Jochen Breuer <jbreuer@suse.de>
|
||||
|
||||
|
13
salt.spec
13
salt.spec
@ -326,6 +326,8 @@ Patch120: info_installed-works-without-status-attr-now.patch
|
||||
Patch121: opensuse-3000.3-spacewalk-runner-parse-command-250.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/openSUSE/salt/pull/251
|
||||
Patch122: opensuse-3000-libvirt-engine-fixes-251.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/58013
|
||||
Patch123: fix-__mount_device-wrapper-254.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: logrotate
|
||||
@ -954,8 +956,15 @@ cp %{S:5} ./.travis.yml
|
||||
%patch120 -p1
|
||||
%patch121 -p1
|
||||
%patch122 -p1
|
||||
%patch123 -p1
|
||||
|
||||
%build
|
||||
# Putting /usr/bin at the front of $PATH is needed for RHEL/RES 7. Without this
|
||||
# change, the RPM will require /bin/python, which is not provided by any package
|
||||
# on RHEL/RES 7.
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
export PATH=/usr/bin:$PATH
|
||||
%endif
|
||||
%if 0%{?build_py2}
|
||||
python setup.py --with-salt-version=%{version} --salt-transport=both build
|
||||
cp ./build/lib/salt/_version.py ./salt
|
||||
@ -1119,8 +1128,10 @@ install -Dpm 0644 pkg/suse/salt-common.logrotate %{buildroot}%{_sysconfdir}/log
|
||||
install -Dpm 0644 pkg/salt-common.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/salt
|
||||
%endif
|
||||
#
|
||||
%if 0%{?suse_version} <= 1500
|
||||
## install SuSEfirewall2 rules
|
||||
install -Dpm 0644 pkg/suse/salt.SuSEfirewall2 %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/salt
|
||||
%endif
|
||||
#
|
||||
## install completion scripts
|
||||
%if %{with bash_completion}
|
||||
@ -1573,7 +1584,9 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version
|
||||
%{_mandir}/man1/salt-key.1.gz
|
||||
%{_mandir}/man1/salt-run.1.gz
|
||||
%{_mandir}/man7/salt.7.gz
|
||||
%if 0%{?suse_version} <= 1500
|
||||
%config(noreplace) %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/salt
|
||||
%endif
|
||||
%{_sbindir}/rcsalt-master
|
||||
%if %{with systemd}
|
||||
%{_unitdir}/salt-master.service
|
||||
|
Loading…
Reference in New Issue
Block a user