-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Issues/29643 fix invalid retcode #31164
Issues/29643 fix invalid retcode #31164
Conversation
Module reload performed by salt.state.State produces new instance of context injection into the state module. This makes the retcode set set at the end of states execution invisible for upstream module caller (minion). This passes current context instance to State to keep it on module reload.
@jacksontj could you please provide your opinion? |
Might also be related to #30674 |
Need this in 2016.3 as well |
…dcode Issues/29643 fix invalid redcode
LGTM :) |
@jacksontj great! Thanks! |
I have a patch that does the same thing that I've been using with 2015.8 for several months. Unfortunately the same patch does not work with the new tornado code that resets |
This is the patch I've been using since October/November 2015:
|
@plastikos I've just tested again with |
@DmitryKuzmenko, I'm pretty certain. This is the whole reason I didn't submit my patch above because it wasn't a general fix anymore with tornado. |
The |
Fixes: #29643
Relates to: #28569
Problem:
Salt highstate is executed. One of states failed. Result retcode is 0.
Expected result retcode: 2.
Explanation:
The problem is the following: minion instance have
functions
LazyLoader
instance keepingcontext
inside. It callsmodules.state.highstate()
that is loaded by the loader and injected with thecontext
instance. Thisstate
module function createsstate.State
instance that creates it's ownLazyLoader
instance with anothercontext'
instance and executes states. Some states uses modules and during modules loading the newcontext'
instance is injected into the modules instead of the old one. By theLazyLoader
design it searches a module to load by matching file names. If no exact nor partial match found it loads modules one-by-one and checks does the module registered the desired name with it's__virtual__
function. So loading using virtual modules suchpkg
could produce loading of the state module with the new loader and injecting the newcontext'
into it.When states execution is finished
modules.state.highstate()
function writesretcode
value into the modulecontext'
dict that was updated by loader. But when it returns minon reads the value from itscontext
dict it keeps in the old loader.Fix:
I've changed
state
module to pass it's__context__
object toState
object that is uses it when it creates the newLazyLoader
instance. This keeps thecontext
instance in all modules called indirectly from thestate
module.