Accepting request 1197433 from systemsmanagement:saltstack
OBS-URL: https://build.opensuse.org/request/show/1197433 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/salt?expand=0&rev=156
This commit is contained in:
commit
2a253503a5
@ -1 +1 @@
|
||||
e793c02a9091b88d181f190847fd35964ce3e91e
|
||||
06f92313dcbe69d75634862b15653b81dc74e340
|
105
join-masters-if-it-is-a-list-671.patch
Normal file
105
join-masters-if-it-is-a-list-671.patch
Normal file
@ -0,0 +1,105 @@
|
||||
From 94973ee85d766d7e98d02d89f4c81e59b36cb716 Mon Sep 17 00:00:00 2001
|
||||
From: Marek Czernek <marek.czernek@suse.com>
|
||||
Date: Thu, 29 Aug 2024 10:01:12 +0200
|
||||
Subject: [PATCH] Join masters if it is a list (#671)
|
||||
|
||||
Co-authored-by: Twangboy <shane.d.lee@gmail.com>
|
||||
---
|
||||
changelog/64170.fixed.md | 2 +
|
||||
salt/utils/cloud.py | 10 +++++
|
||||
tests/pytests/unit/utils/test_cloud.py | 52 ++++++++++++++++++++++++++
|
||||
3 files changed, 64 insertions(+)
|
||||
create mode 100644 changelog/64170.fixed.md
|
||||
|
||||
diff --git a/changelog/64170.fixed.md b/changelog/64170.fixed.md
|
||||
new file mode 100644
|
||||
index 0000000000..1d20355bf1
|
||||
--- /dev/null
|
||||
+++ b/changelog/64170.fixed.md
|
||||
@@ -0,0 +1,2 @@
|
||||
+Fixed issue in salt-cloud so that multiple masters specified in the cloud
|
||||
+are written to the minion config properly
|
||||
diff --git a/salt/utils/cloud.py b/salt/utils/cloud.py
|
||||
index b7208dc4a6..a084313059 100644
|
||||
--- a/salt/utils/cloud.py
|
||||
+++ b/salt/utils/cloud.py
|
||||
@@ -1202,6 +1202,16 @@ def wait_for_passwd(
|
||||
time.sleep(trysleep)
|
||||
|
||||
|
||||
+def _format_master_param(master):
|
||||
+ """
|
||||
+ If the master is a list, we need to convert it to a comma delimited string
|
||||
+ Otherwise, we just return master
|
||||
+ """
|
||||
+ if isinstance(master, list):
|
||||
+ return ",".join(master)
|
||||
+ return master
|
||||
+
|
||||
+
|
||||
def deploy_windows(
|
||||
host,
|
||||
port=445,
|
||||
diff --git a/tests/pytests/unit/utils/test_cloud.py b/tests/pytests/unit/utils/test_cloud.py
|
||||
index 550b63c974..db9d258d39 100644
|
||||
--- a/tests/pytests/unit/utils/test_cloud.py
|
||||
+++ b/tests/pytests/unit/utils/test_cloud.py
|
||||
@@ -605,3 +605,55 @@ def test_deploy_script_ssh_timeout():
|
||||
ssh_kwargs = root_cmd.call_args.kwargs
|
||||
assert "ssh_timeout" in ssh_kwargs
|
||||
assert ssh_kwargs["ssh_timeout"] == 34
|
||||
+
|
||||
+
|
||||
+@pytest.mark.parametrize(
|
||||
+ "master,expected",
|
||||
+ [
|
||||
+ (None, None),
|
||||
+ ("single_master", "single_master"),
|
||||
+ (["master1", "master2", "master3"], "master1,master2,master3"),
|
||||
+ ],
|
||||
+)
|
||||
+def test__format_master_param(master, expected):
|
||||
+ result = cloud._format_master_param(master)
|
||||
+ assert result == expected
|
||||
+
|
||||
+
|
||||
+@pytest.mark.skip_unless_on_windows(reason="Only applicable for Windows.")
|
||||
+@pytest.mark.parametrize(
|
||||
+ "master,expected",
|
||||
+ [
|
||||
+ (None, None),
|
||||
+ ("single_master", "single_master"),
|
||||
+ (["master1", "master2", "master3"], "master1,master2,master3"),
|
||||
+ ],
|
||||
+)
|
||||
+def test_deploy_windows_master(master, expected):
|
||||
+ """
|
||||
+ Test deploy_windows with master parameter
|
||||
+ """
|
||||
+ mock_true = MagicMock(return_value=True)
|
||||
+ mock_tuple = MagicMock(return_value=(0, 0, 0))
|
||||
+ with patch("salt.utils.smb.get_conn", MagicMock()), patch(
|
||||
+ "salt.utils.smb.mkdirs", MagicMock()
|
||||
+ ), patch("salt.utils.smb.put_file", MagicMock()), patch(
|
||||
+ "salt.utils.smb.delete_file", MagicMock()
|
||||
+ ), patch(
|
||||
+ "salt.utils.smb.delete_directory", MagicMock()
|
||||
+ ), patch(
|
||||
+ "time.sleep", MagicMock()
|
||||
+ ), patch.object(
|
||||
+ cloud, "wait_for_port", mock_true
|
||||
+ ), patch.object(
|
||||
+ cloud, "fire_event", MagicMock()
|
||||
+ ), patch.object(
|
||||
+ cloud, "wait_for_psexecsvc", mock_true
|
||||
+ ), patch.object(
|
||||
+ cloud, "run_psexec_command", mock_tuple
|
||||
+ ) as mock:
|
||||
+ cloud.deploy_windows(host="test", win_installer="install.exe", master=master)
|
||||
+ expected_cmd = "c:\\salttemp\\install.exe"
|
||||
+ expected_args = "/S /master={} /minion-name=None".format(expected)
|
||||
+ assert mock.call_args_list[0].args[0] == expected_cmd
|
||||
+ assert mock.call_args_list[0].args[1] == expected_args
|
||||
--
|
||||
2.44.0
|
||||
|
122
replace-use-of-pygit2-deprecated-and-removed-1.15.0-.patch
Normal file
122
replace-use-of-pygit2-deprecated-and-removed-1.15.0-.patch
Normal file
@ -0,0 +1,122 @@
|
||||
From 3f3c8d80427c9d90bea5fbca785b210260d33a0f Mon Sep 17 00:00:00 2001
|
||||
From: Marek Czernek <marek.czernek@suse.com>
|
||||
Date: Wed, 21 Aug 2024 16:15:02 +0200
|
||||
Subject: [PATCH] Replace use of pygit2 deprecated and removed (1.15.0)
|
||||
oid with id (#673)
|
||||
|
||||
Co-authored-by: David Murphy <damurphy@vmware.com>
|
||||
---
|
||||
salt/utils/gitfs.py | 31 ++++++++++++++++---------------
|
||||
1 file changed, 16 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py
|
||||
index 061647edaca..f3902c1f19a 100644
|
||||
--- a/salt/utils/gitfs.py
|
||||
+++ b/salt/utils/gitfs.py
|
||||
@@ -1683,7 +1683,7 @@ class Pygit2(GitProvider):
|
||||
# remote ref.
|
||||
self.repo.checkout(checkout_ref)
|
||||
if branch:
|
||||
- self.repo.reset(oid, pygit2.GIT_RESET_HARD)
|
||||
+ self.repo.reset(pygit2_id, pygit2.GIT_RESET_HARD)
|
||||
return True
|
||||
except GitLockError as exc:
|
||||
if exc.errno == errno.EEXIST:
|
||||
@@ -1714,11 +1714,11 @@ class Pygit2(GitProvider):
|
||||
tag_ref = "refs/tags/" + tgt_ref
|
||||
if remote_ref in refs:
|
||||
# Get commit id for the remote ref
|
||||
- oid = self.peel(self.repo.lookup_reference(remote_ref)).id
|
||||
+ pygit2_id = self.peel(self.repo.lookup_reference(remote_ref)).id
|
||||
if local_ref not in refs:
|
||||
# No local branch for this remote, so create one and point
|
||||
# it at the commit id of the remote ref
|
||||
- self.repo.create_reference(local_ref, oid)
|
||||
+ self.repo.create_reference(local_ref, pygit2_id)
|
||||
|
||||
try:
|
||||
target_sha = self.peel(self.repo.lookup_reference(remote_ref)).hex
|
||||
@@ -1749,7 +1749,8 @@ class Pygit2(GitProvider):
|
||||
# cachedir).
|
||||
head_ref = local_head.target
|
||||
# If head_ref is not a string, it will point to a
|
||||
- # pygit2.Oid object and we are in detached HEAD mode.
|
||||
+ # pygit2.id object (oid is deprecated and removed) and
|
||||
+ # we are in detached HEAD mode.
|
||||
# Therefore, there is no need to add a local reference. If
|
||||
# head_ref == local_ref, then the local reference for HEAD
|
||||
# in refs/heads/ already exists and again, no need to add.
|
||||
@@ -1918,10 +1919,10 @@ class Pygit2(GitProvider):
|
||||
the empty directories within it in the "blobs" list
|
||||
"""
|
||||
for entry in iter(tree):
|
||||
- if entry.oid not in self.repo:
|
||||
+ if entry.id not in self.repo:
|
||||
# Entry is a submodule, skip it
|
||||
continue
|
||||
- blob = self.repo[entry.oid]
|
||||
+ blob = self.repo[entry.id]
|
||||
if not isinstance(blob, pygit2.Tree):
|
||||
continue
|
||||
blobs.append(
|
||||
@@ -1940,8 +1941,8 @@ class Pygit2(GitProvider):
|
||||
return ret
|
||||
if self.root(tgt_env):
|
||||
try:
|
||||
- oid = tree[self.root(tgt_env)].oid
|
||||
- tree = self.repo[oid]
|
||||
+ pygit2_id = tree[self.root(tgt_env)].id
|
||||
+ tree = self.repo[pygit2_id]
|
||||
except KeyError:
|
||||
return ret
|
||||
if not isinstance(tree, pygit2.Tree):
|
||||
@@ -2056,17 +2057,17 @@ class Pygit2(GitProvider):
|
||||
the file paths and symlink info in the "blobs" dict
|
||||
"""
|
||||
for entry in iter(tree):
|
||||
- if entry.oid not in self.repo:
|
||||
+ if entry.id not in self.repo:
|
||||
# Entry is a submodule, skip it
|
||||
continue
|
||||
- obj = self.repo[entry.oid]
|
||||
+ obj = self.repo[entry.id]
|
||||
if isinstance(obj, pygit2.Blob):
|
||||
repo_path = salt.utils.path.join(
|
||||
prefix, entry.name, use_posixpath=True
|
||||
)
|
||||
blobs.setdefault("files", []).append(repo_path)
|
||||
if stat.S_ISLNK(tree[entry.name].filemode):
|
||||
- link_tgt = self.repo[tree[entry.name].oid].data
|
||||
+ link_tgt = self.repo[tree[entry.name].id].data
|
||||
blobs.setdefault("symlinks", {})[repo_path] = link_tgt
|
||||
elif isinstance(obj, pygit2.Tree):
|
||||
_traverse(
|
||||
@@ -2085,8 +2086,8 @@ class Pygit2(GitProvider):
|
||||
try:
|
||||
# This might need to be changed to account for a root that
|
||||
# spans more than one directory
|
||||
- oid = tree[self.root(tgt_env)].oid
|
||||
- tree = self.repo[oid]
|
||||
+ pygit2_id = tree[self.root(tgt_env)].id
|
||||
+ tree = self.repo[pygit2_id]
|
||||
except KeyError:
|
||||
return files, symlinks
|
||||
if not isinstance(tree, pygit2.Tree):
|
||||
@@ -2130,12 +2131,12 @@ class Pygit2(GitProvider):
|
||||
# path's object ID will be the target of the symlink. Follow
|
||||
# the symlink and set path to the location indicated
|
||||
# in the blob data.
|
||||
- link_tgt = self.repo[entry.oid].data
|
||||
+ link_tgt = self.repo[entry.id].data
|
||||
path = salt.utils.path.join(
|
||||
os.path.dirname(path), link_tgt, use_posixpath=True
|
||||
)
|
||||
else:
|
||||
- blob = self.repo[entry.oid]
|
||||
+ blob = self.repo[entry.id]
|
||||
if isinstance(blob, pygit2.Tree):
|
||||
# Path is a directory, not a file.
|
||||
blob = None
|
||||
--
|
||||
2.46.0
|
||||
|
16
salt.changes
16
salt.changes
@ -1,3 +1,19 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Aug 29 11:54:27 UTC 2024 - Yeray Gutiérrez Cedrés <yeray.gutierrez@suse.com>
|
||||
|
||||
- Fix cloud minion configuration for multiple masters (bsc#1229109)
|
||||
|
||||
- Added:
|
||||
* join-masters-if-it-is-a-list-671.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Aug 21 14:30:48 UTC 2024 - Marek Czernek <marek.czernek@suse.com>
|
||||
|
||||
- Use Pygit2 id instead of deprecated oid in gitfs
|
||||
|
||||
- Added:
|
||||
* replace-use-of-pygit2-deprecated-and-removed-1.15.0-.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Aug 7 09:45:18 UTC 2024 - Marek Czernek <marek.czernek@suse.com>
|
||||
|
||||
|
@ -415,6 +415,11 @@ Patch127: skip-more-tests-related-to-old-openssl-algorithms.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/662
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/66730
|
||||
Patch128: make-tests-compatible-with-venv-bundle.patch
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/66743
|
||||
Patch129: replace-use-of-pygit2-deprecated-and-removed-1.15.0-.patch
|
||||
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/671
|
||||
# PATCH-FIX_UPSTREAM: https://github.com/saltstack/salt/pull/64173
|
||||
Patch130: join-masters-if-it-is-a-list-671.patch
|
||||
|
||||
### IMPORTANT: The line below is used as a snippet marker. Do not touch it.
|
||||
### SALT PATCHES LIST END
|
||||
|
Loading…
Reference in New Issue
Block a user