Skip to content

Commit 851f61e

Browse files
authored
Merge pull request #69200 from lkubb/fix-ssh-synced-extmods
Salt-SSH: Fix internal modules being synced as external ones
2 parents ff8706c + 4bfffdf commit 851f61e

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

changelog/69199.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed Salt-SSH syncing internal modules as extmods

salt/client/ssh/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,6 +1757,10 @@ def mod_data(fsclient):
17571757
if not os.path.isdir(mod_dir):
17581758
continue
17591759

1760+
# Skip internal salt modules - they should be in the thin/relenv tarball
1761+
if mod_dir.startswith(str(salt.loader.SALT_BASE_PATH)):
1762+
continue
1763+
17601764
for fn_ in os.listdir(mod_dir):
17611765
if fn_.endswith((".py", ".so", ".pyx")) and not fn_.startswith(
17621766
"__"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import re
2+
3+
import salt.client.ssh
4+
import salt.fileclient
5+
from tests.support.mock import MagicMock, patch
6+
7+
8+
def test_internal_modules_are_not_synced_as_extmods(master_opts):
9+
fsclient = salt.fileclient.FSClient(master_opts)
10+
tar = MagicMock()
11+
with patch("tarfile.open", return_value=tar):
12+
salt.client.ssh.mod_data(fsclient)
13+
ptrn = re.compile(
14+
r".*/salt/(modules|states|grains|renderers|returners|utils)/\w+\.py$"
15+
)
16+
for call in tar.add.call_args_list:
17+
assert not ptrn.match(call[0][0])

0 commit comments

Comments
 (0)