-
Notifications
You must be signed in to change notification settings - Fork 52
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
Allow explicit reboot on transactional minions #643
base: openSUSE/release/3006.0
Are you sure you want to change the base?
Changes from 11 commits
3c06882
c0e081e
d4642ef
89609c8
7a7f7a1
a63e2a3
7bb6f29
cf97edd
cf48e16
43acc0f
8ec03a2
86d6235
862216d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -985,13 +985,40 @@ def call(function, *args, **kwargs): | |
else: | ||
return local | ||
except ValueError: | ||
return {"result": False, "retcode": 1, "comment": ret_stdout} | ||
local = {"result": False, "retcode": 1, "comment": ret_stdout} | ||
return local | ||
finally: | ||
# Check if reboot is needed | ||
if activate_transaction and pending_transaction(): | ||
if (activate_transaction and pending_transaction()) or ( | ||
not kwargs.get("test", False) and _user_specified_reboot(local, function) | ||
): | ||
reboot() | ||
|
||
|
||
def _user_specified_reboot(local, function): | ||
if function != "state.highstate" and function != "state.sls": | ||
return False | ||
|
||
if not isinstance(local, dict): | ||
return False | ||
|
||
explicit_reboot_cmds = set(["reboot", "system.reboot"]) | ||
explicit_reboot_modules = ["cmd_", "module_"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it's a bit wrong to specify here
I don't know why but actually, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense,thank you for the suggestion! Implemented. |
||
names = set() | ||
for full_module_name, module_result in local.items(): | ||
if not isinstance(full_module_name, str): | ||
continue | ||
|
||
module = full_module_name.split("|")[0] | ||
m-czernek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if module not in explicit_reboot_modules: | ||
continue | ||
|
||
if isinstance(module_result, dict) and "name" in module_result: | ||
names.add(module_result["name"]) | ||
|
||
return bool(explicit_reboot_cmds.intersection(names)) | ||
|
||
|
||
def apply_(mods=None, **kwargs): | ||
"""Apply an state inside a transaction. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we need to cover all of these functions:
salt/salt/executors/transactional_update.py
Lines 14 to 19 in 86d6235
Actually
state.highstate
is not widely used in Uyuni/SUMA, but mostlystate.apply
with nomods
specified (asstate.apply
with no mods is acting asstate.highstate
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, great catch - didn't want to maintain the list of functions in two places, so I pulled in the
DELEGATION_MAP
directly. WTYD?