2022-01-27 16:38:33 +01:00
|
|
|
From 5d7b9be571b765faae5cefc5a0810c61c2a25814 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Alexander Graul <agraul@suse.com>
|
|
|
|
Date: Tue, 18 Jan 2022 17:36:12 +0100
|
2021-09-27 12:08:32 +02:00
|
|
|
Subject: [PATCH] Support transactional systems (MicroOS)
|
|
|
|
|
|
|
|
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 #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
|
|
|
|
---
|
2022-01-27 16:38:33 +01:00
|
|
|
changelog/58519.added | 1 +
|
|
|
|
salt/modules/chroot.py | 10 +++++++---
|
|
|
|
salt/modules/transactional_update.py | 8 ++++----
|
|
|
|
.../unit/modules/test_transactional_update.py | 10 +++++++++-
|
|
|
|
tests/unit/modules/test_chroot.py | 13 ++++++++++++-
|
|
|
|
5 files changed, 33 insertions(+), 9 deletions(-)
|
2021-09-27 12:08:32 +02:00
|
|
|
create mode 100644 changelog/58519.added
|
|
|
|
|
|
|
|
diff --git a/changelog/58519.added b/changelog/58519.added
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000000..1cc8d7dc74
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/changelog/58519.added
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+Add support for transactional systems, like openSUSE MicroOS
|
|
|
|
\ No newline at end of file
|
|
|
|
diff --git a/salt/modules/chroot.py b/salt/modules/chroot.py
|
2022-01-27 16:38:33 +01:00
|
|
|
index 39dfff6b86..91f139455b 100644
|
2021-09-27 12:08:32 +02:00
|
|
|
--- a/salt/modules/chroot.py
|
|
|
|
+++ b/salt/modules/chroot.py
|
2022-01-27 16:38:33 +01:00
|
|
|
@@ -242,7 +242,11 @@ def _create_and_execute_salt_state(root, chunks, file_refs, test, hash_type):
|
2021-09-27 12:08:32 +02:00
|
|
|
# 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)
|
|
|
|
|
2022-01-27 16:38:33 +01:00
|
|
|
@@ -303,7 +307,7 @@ def sls(root, mods, saltenv="base", test=None, exclude=None, **kwargs):
|
2021-09-27 12:08:32 +02:00
|
|
|
"""
|
|
|
|
# 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
|
2022-01-27 16:38:33 +01:00
|
|
|
@@ -372,7 +376,7 @@ def highstate(root, **kwargs):
|
2021-09-27 12:08:32 +02:00
|
|
|
"""
|
|
|
|
# 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
|
|
|
|
diff --git a/salt/modules/transactional_update.py b/salt/modules/transactional_update.py
|
2022-01-27 16:38:33 +01:00
|
|
|
index 6fcad40b35..799fe08e4d 100644
|
|
|
|
--- a/salt/modules/transactional_update.py
|
2021-09-27 12:08:32 +02:00
|
|
|
+++ b/salt/modules/transactional_update.py
|
2022-01-27 16:38:33 +01:00
|
|
|
@@ -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__
|
2021-09-27 12:08:32 +02:00
|
|
|
+ salt.fileclient.get_file_client(__opts__), chunks, file_refs, __pillar__.value()
|
2022-01-27 16:38:33 +01:00
|
|
|
)
|
|
|
|
trans_tar_sum = salt.utils.hashutils.get_hash(trans_tar, hash_type)
|
2021-09-27 12:08:32 +02:00
|
|
|
|
2022-01-27 16:38:33 +01:00
|
|
|
@@ -1134,7 +1134,7 @@ def sls(
|
2021-09-27 12:08:32 +02:00
|
|
|
|
2022-01-27 16:38:33 +01:00
|
|
|
# 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", {}))
|
2021-09-27 12:08:32 +02:00
|
|
|
|
2022-01-27 16:38:33 +01:00
|
|
|
# Clone the options data and apply some default values. May not be
|
|
|
|
@@ -1218,7 +1218,7 @@ def highstate(activate_transaction=False, queue=False, **kwargs):
|
2021-09-27 12:08:32 +02:00
|
|
|
|
2022-01-27 16:38:33 +01:00
|
|
|
# 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", {}))
|
2021-09-27 12:08:32 +02:00
|
|
|
|
2022-01-27 16:38:33 +01:00
|
|
|
# Clone the options data and apply some default values. May not be
|
|
|
|
@@ -1284,7 +1284,7 @@ def single(fun, name, test=None, activate_transaction=False, queue=False, **kwar
|
2021-09-27 12:08:32 +02:00
|
|
|
|
2022-01-27 16:38:33 +01:00
|
|
|
# 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", {}))
|
2021-09-27 12:08:32 +02:00
|
|
|
|
2022-01-27 16:38:33 +01:00
|
|
|
# Clone the options data and apply some default values. May not be
|
2021-09-27 12:08:32 +02:00
|
|
|
diff --git a/tests/pytests/unit/modules/test_transactional_update.py b/tests/pytests/unit/modules/test_transactional_update.py
|
2022-01-27 16:38:33 +01:00
|
|
|
index f9eb1fd595..032ca0c9e8 100644
|
|
|
|
--- a/tests/pytests/unit/modules/test_transactional_update.py
|
2021-09-27 12:08:32 +02:00
|
|
|
+++ b/tests/pytests/unit/modules/test_transactional_update.py
|
2022-01-27 16:38:33 +01:00
|
|
|
@@ -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
|
|
|
|
@@ -13,8 +14,15 @@ pytestmark = [
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def configure_loader_modules():
|
|
|
|
+ loader_context = salt.loader.context.LoaderContext()
|
|
|
|
return {
|
|
|
|
- tu: {"__salt__": {}, "__utils__": {}},
|
2021-09-27 12:08:32 +02:00
|
|
|
+ tu: {
|
|
|
|
+ "__salt__": {},
|
|
|
|
+ "__utils__": {},
|
2022-01-27 16:38:33 +01:00
|
|
|
+ "__pillar__": salt.loader.context.NamedLoaderContext(
|
2021-09-27 12:08:32 +02:00
|
|
|
+ "__pillar__", loader_context, {}
|
|
|
|
+ ),
|
|
|
|
+ },
|
2022-01-27 16:38:33 +01:00
|
|
|
statemod: {"__salt__": {}, "__context__": {}},
|
|
|
|
}
|
2021-09-27 12:08:32 +02:00
|
|
|
|
|
|
|
diff --git a/tests/unit/modules/test_chroot.py b/tests/unit/modules/test_chroot.py
|
2022-01-27 16:38:33 +01:00
|
|
|
index cdbfcb0fab..9cdfeaf066 100644
|
2021-09-27 12:08:32 +02:00
|
|
|
--- a/tests/unit/modules/test_chroot.py
|
|
|
|
+++ b/tests/unit/modules/test_chroot.py
|
2022-01-27 16:38:33 +01:00
|
|
|
@@ -27,6 +27,7 @@
|
2021-09-27 12:08:32 +02:00
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2022-01-27 16:38:33 +01:00
|
|
|
+import salt.loader.context
|
2021-09-27 12:08:32 +02:00
|
|
|
import salt.modules.chroot as chroot
|
|
|
|
import salt.utils.platform
|
|
|
|
from salt.exceptions import CommandExecutionError
|
2022-01-27 16:38:33 +01:00
|
|
|
@@ -42,7 +43,17 @@ class ChrootTestCase(TestCase, LoaderModuleMockMixin):
|
2021-09-27 12:08:32 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
def setup_loader_modules(self):
|
|
|
|
- return {chroot: {"__salt__": {}, "__utils__": {}, "__opts__": {"cachedir": ""}}}
|
2022-01-27 16:38:33 +01:00
|
|
|
+ loader_context = salt.loader.context.LoaderContext()
|
2021-09-27 12:08:32 +02:00
|
|
|
+ return {
|
|
|
|
+ chroot: {
|
|
|
|
+ "__salt__": {},
|
|
|
|
+ "__utils__": {},
|
|
|
|
+ "__opts__": {"cachedir": ""},
|
2022-01-27 16:38:33 +01:00
|
|
|
+ "__pillar__": salt.loader.context.NamedLoaderContext(
|
2021-09-27 12:08:32 +02:00
|
|
|
+ "__pillar__", loader_context, {}
|
|
|
|
+ ),
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@patch("os.path.isdir")
|
|
|
|
def test_exist(self, isdir):
|
|
|
|
--
|
2022-01-27 16:38:33 +01:00
|
|
|
2.34.1
|
2021-09-27 12:08:32 +02:00
|
|
|
|
|
|
|
|