Skip to content

Commit

Permalink
Support transactional systems (MicroOS)
Browse files Browse the repository at this point in the history
Add rebootmgr module

Add transactional_update module

chroot: add chroot detector

systemd: add offline mode detector

transactional_update: add pending_transaction detector

extra: add EFI and transactional grains

transactional_update: add call, apply_, sls & highstate

transactional_update: add documentation

transactional_update: add executor

Add changelog entry 58519.added

Closes saltstack#58519

transactional_update: update the cleanups family

transactional_update: add activate_transaction param

transactional_update: skip tests on Windows

transactional_update: unify with chroot.call

Return for both .call() "retcode" when fail

Add MicroOS information in release note

systemd: support NamedLoaderContext

transactional_update: detect recursion in the executor

Handle master tops data when states are applied by transactional_update

Fix unit tests for transactional_update module

Do noop for services states when running systemd in offline mode

transactional_updates: do not execute states in parallel but use a queue

Add changes suggested by pre-commit

Fix unit tests for transactional_updates module

Add unit tests to cover queue cases on transaction_update states

Refactor offline checkers and add unit tests

Fix regression that always consider offline mode

Add proper mocking and skip tests when running in offline mode

Fix failing unit tests for systemd

test_rebootmgr: convert to pytest

test_transactional_update: convert to pytest

Update release documentation to 3004
  • Loading branch information
agraul committed Jan 21, 2022
1 parent 6375b8a commit 5f0cdf8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog/58519.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for transactional systems, like openSUSE MicroOS
10 changes: 7 additions & 3 deletions salt/modules/chroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ def _create_and_execute_salt_state(root, chunks, file_refs, test, hash_type):
# Create the tar containing the state pkg and relevant files.
salt.client.ssh.wrapper.state._cleanup_slsmod_low_data(chunks)
trans_tar = salt.client.ssh.state.prep_trans_tar(
salt.fileclient.get_file_client(__opts__), chunks, file_refs, __pillar__, root
salt.fileclient.get_file_client(__opts__),
chunks,
file_refs,
__pillar__.value(),
root,
)
trans_tar_sum = salt.utils.hashutils.get_hash(trans_tar, hash_type)

Expand Down Expand Up @@ -303,7 +307,7 @@ def sls(root, mods, saltenv="base", test=None, exclude=None, **kwargs):
"""
# Get a copy of the pillar data, to avoid overwriting the current
# pillar, instead the one delegated
pillar = copy.deepcopy(__pillar__)
pillar = copy.deepcopy(__pillar__.value())
pillar.update(kwargs.get("pillar", {}))

# Clone the options data and apply some default values. May not be
Expand Down Expand Up @@ -372,7 +376,7 @@ def highstate(root, **kwargs):
"""
# Get a copy of the pillar data, to avoid overwriting the current
# pillar, instead the one delegated
pillar = copy.deepcopy(__pillar__)
pillar = copy.deepcopy(__pillar__.value())
pillar.update(kwargs.get("pillar", {}))

# Clone the options data and apply some default values. May not be
Expand Down
8 changes: 4 additions & 4 deletions salt/modules/transactional_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ def _create_and_execute_salt_state(
# Create the tar containing the state pkg and relevant files.
salt.client.ssh.wrapper.state._cleanup_slsmod_low_data(chunks)
trans_tar = salt.client.ssh.state.prep_trans_tar(
salt.fileclient.get_file_client(__opts__), chunks, file_refs, __pillar__
salt.fileclient.get_file_client(__opts__), chunks, file_refs, __pillar__.value()
)
trans_tar_sum = salt.utils.hashutils.get_hash(trans_tar, hash_type)

Expand Down Expand Up @@ -1134,7 +1134,7 @@ def sls(

# Get a copy of the pillar data, to avoid overwriting the current
# pillar, instead the one delegated
pillar = copy.deepcopy(__pillar__)
pillar = copy.deepcopy(__pillar__.value())
pillar.update(kwargs.get("pillar", {}))

# Clone the options data and apply some default values. May not be
Expand Down Expand Up @@ -1218,7 +1218,7 @@ def highstate(activate_transaction=False, queue=False, **kwargs):

# Get a copy of the pillar data, to avoid overwriting the current
# pillar, instead the one delegated
pillar = copy.deepcopy(__pillar__)
pillar = copy.deepcopy(__pillar__.value())
pillar.update(kwargs.get("pillar", {}))

# Clone the options data and apply some default values. May not be
Expand Down Expand Up @@ -1284,7 +1284,7 @@ def single(fun, name, test=None, activate_transaction=False, queue=False, **kwar

# Get a copy of the pillar data, to avoid overwriting the current
# pillar, instead the one delegated
pillar = copy.deepcopy(__pillar__)
pillar = copy.deepcopy(__pillar__.value())
pillar.update(kwargs.get("pillar", {}))

# Clone the options data and apply some default values. May not be
Expand Down
10 changes: 9 additions & 1 deletion tests/pytests/unit/modules/test_transactional_update.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys

import pytest
import salt.loader.context
import salt.modules.state as statemod
import salt.modules.transactional_update as tu
from salt.exceptions import CommandExecutionError
Expand All @@ -13,8 +14,15 @@

@pytest.fixture
def configure_loader_modules():
loader_context = salt.loader.context.LoaderContext()
return {
tu: {"__salt__": {}, "__utils__": {}},
tu: {
"__salt__": {},
"__utils__": {},
"__pillar__": salt.loader.context.NamedLoaderContext(
"__pillar__", loader_context, {}
),
},
statemod: {"__salt__": {}, "__context__": {}},
}

Expand Down
13 changes: 12 additions & 1 deletion tests/unit/modules/test_chroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import sys

import salt.loader.context
import salt.modules.chroot as chroot
import salt.utils.platform
from salt.exceptions import CommandExecutionError
Expand All @@ -42,7 +43,17 @@ class ChrootTestCase(TestCase, LoaderModuleMockMixin):
"""

def setup_loader_modules(self):
return {chroot: {"__salt__": {}, "__utils__": {}, "__opts__": {"cachedir": ""}}}
loader_context = salt.loader.context.LoaderContext()
return {
chroot: {
"__salt__": {},
"__utils__": {},
"__opts__": {"cachedir": ""},
"__pillar__": salt.loader.context.NamedLoaderContext(
"__pillar__", loader_context, {}
),
}
}

@patch("os.path.isdir")
def test_exist(self, isdir):
Expand Down

0 comments on commit 5f0cdf8

Please sign in to comment.