Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chroot: add apply_, sls and highstate for state execution #55345

Merged
merged 12 commits into from
Dec 3, 2019
Prev Previous commit
Next Next commit
chroot: workaround to a connection bug in salt
Some bug in Salt is preventing to use `archive.tar` inside chroot, we we
want to untar the salt_thin.tgz.

This bug is related with how much deep is the stack of __salt__ calls,
and do not clossing some connections to the master.

Tracking the AsyncZeroMQChannel connections to master:4506, we can see
that one is not closed once the actions ends, hanging the salt-call CLI.

This commit will be reverted once the root cause in found, and the bug
fixed.
  • Loading branch information
aplanas committed Nov 21, 2019
commit 461036385e491d7305acc6e7058322b52c31f7c2
9 changes: 8 additions & 1 deletion salt/modules/chroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@ def call(root, function, *args, **kwargs):
extra_mods=__salt__['config.option']('thin_extra_mods', ''),
so_mods=__salt__['config.option']('thin_so_mods', '')
)
stdout = __salt__['archive.tar']('xzf', thin_path, dest=thin_dest_path)
# Some bug in Salt is preventing us to use `archive.tar` here. A
# AsyncZeroMQReqChannel is not closed at the end os the salt-call,
# and makes the client never exit.
#
# stdout = __salt__['archive.tar']('xzf', thin_path, dest=thin_dest_path)
#
stdout = __salt__['cmd.run'](['tar', 'xzf', thin_path,
'-C', thin_dest_path])
if stdout:
__utils__['files.rm_rf'](thin_dest_path)
return {'result': False, 'comment': stdout}
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/modules/test_chroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_call_fails_untar(self, mkdtemp, exist):
'files.rm_rf': MagicMock(),
}
salt_mock = {
'archive.tar': MagicMock(return_value='Error'),
'cmd.run': MagicMock(return_value='Error'),
'config.option': MagicMock(),
}
with patch.dict(chroot.__utils__, utils_mock), \
Expand All @@ -121,7 +121,7 @@ def test_call_fails_untar(self, mkdtemp, exist):
})
utils_mock['thin.gen_thin'].assert_called_once()
salt_mock['config.option'].assert_called()
salt_mock['archive.tar'].assert_called_once()
salt_mock['cmd.run'].assert_called_once()
utils_mock['files.rm_rf'].assert_called_once()

@patch('salt.modules.chroot.exist')
Expand All @@ -138,7 +138,7 @@ def test_call_fails_salt_thin(self, mkdtemp, exist):
'files.rm_rf': MagicMock(),
}
salt_mock = {
'archive.tar': MagicMock(return_value=''),
'cmd.run': MagicMock(return_value=''),
'config.option': MagicMock(),
'cmd.run_chroot': MagicMock(return_value={
'retcode': 1,
Expand All @@ -151,7 +151,7 @@ def test_call_fails_salt_thin(self, mkdtemp, exist):
'test.ping')
utils_mock['thin.gen_thin'].assert_called_once()
salt_mock['config.option'].assert_called()
salt_mock['archive.tar'].assert_called_once()
salt_mock['cmd.run'].assert_called_once()
salt_mock['cmd.run_chroot'].assert_called_with(
'/chroot',
['python{}'.format(sys.version_info[0]), '/tmp01/salt-call',
Expand All @@ -175,7 +175,7 @@ def test_call_success(self, mkdtemp, exist):
'json.find_json': MagicMock(return_value={'return': 'result'})
}
salt_mock = {
'archive.tar': MagicMock(return_value=''),
'cmd.run': MagicMock(return_value=''),
'config.option': MagicMock(),
'cmd.run_chroot': MagicMock(return_value={
'retcode': 0,
Expand All @@ -187,7 +187,7 @@ def test_call_success(self, mkdtemp, exist):
self.assertEqual(chroot.call('/chroot', 'test.ping'), 'result')
utils_mock['thin.gen_thin'].assert_called_once()
salt_mock['config.option'].assert_called()
salt_mock['archive.tar'].assert_called_once()
salt_mock['cmd.run'].assert_called_once()
salt_mock['cmd.run_chroot'].assert_called_with(
'/chroot',
['python{}'.format(sys.version_info[0]), '/tmp01/salt-call',
Expand All @@ -211,7 +211,7 @@ def test_call_success_parameters(self, mkdtemp, exist):
'json.find_json': MagicMock(return_value={'return': 'result'})
}
salt_mock = {
'archive.tar': MagicMock(return_value=''),
'cmd.run': MagicMock(return_value=''),
'config.option': MagicMock(),
'cmd.run_chroot': MagicMock(return_value={
'retcode': 0,
Expand All @@ -224,7 +224,7 @@ def test_call_success_parameters(self, mkdtemp, exist):
key='value'), 'result')
utils_mock['thin.gen_thin'].assert_called_once()
salt_mock['config.option'].assert_called()
salt_mock['archive.tar'].assert_called_once()
salt_mock['cmd.run'].assert_called_once()
salt_mock['cmd.run_chroot'].assert_called_with(
'/chroot',
['python{}'.format(sys.version_info[0]), '/tmp01/salt-call',
Expand Down