diff --git a/changelog/69199.fixed.md b/changelog/69199.fixed.md new file mode 100644 index 000000000000..90e31cbdba3d --- /dev/null +++ b/changelog/69199.fixed.md @@ -0,0 +1 @@ +Fixed Salt-SSH syncing internal modules as extmods diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py index 960362ec05a0..9488a88756c9 100644 --- a/salt/client/ssh/__init__.py +++ b/salt/client/ssh/__init__.py @@ -1742,6 +1742,10 @@ def mod_data(fsclient): if not os.path.isdir(mod_dir): continue + # Skip internal salt modules - they should be in the thin/relenv tarball + if mod_dir.startswith(str(salt.loader.SALT_BASE_PATH)): + continue + for fn_ in os.listdir(mod_dir): if fn_.endswith((".py", ".so", ".pyx")) and not fn_.startswith( "__" diff --git a/tests/pytests/unit/client/ssh/test_extmods.py b/tests/pytests/unit/client/ssh/test_extmods.py new file mode 100644 index 000000000000..354581196506 --- /dev/null +++ b/tests/pytests/unit/client/ssh/test_extmods.py @@ -0,0 +1,17 @@ +import re + +import salt.client.ssh +import salt.fileclient +from tests.support.mock import MagicMock, patch + + +def test_internal_modules_are_not_synced_as_extmods(master_opts): + fsclient = salt.fileclient.FSClient(master_opts) + tar = MagicMock() + with patch("tarfile.open", return_value=tar): + salt.client.ssh.mod_data(fsclient) + ptrn = re.compile( + r".*/salt/(modules|states|grains|renderers|returners|utils)/\w+\.py$" + ) + for call in tar.add.call_args_list: + assert not ptrn.match(call[0][0])