Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

SEP 24: Add sub_state_return #32

Merged
merged 4 commits into from
Feb 11, 2021
Merged

Conversation

Akm0d
Copy link
Contributor

@Akm0d Akm0d commented Aug 12, 2020

Add the ability for states to have sub_state_runs so that state output from modules that can execute multiple states/SLSs/configurations/plays simultaneously can very clear and verbose.

@Akm0d Akm0d requested a review from a team as a code owner August 12, 2020 22:45
@ghost ghost requested review from waynew and removed request for a team August 12, 2020 22:45
@OrangeDog
Copy link

OrangeDog commented Aug 13, 2020

Should this also cover "internal" sub-states? There are a few states that call file.managed internally, for example.

This talks a lot about the motivation and impact on idem, but what about the regular salt engine?
What are the internal and observable changes to e.g. the ansible states, and would they require e.g. changes to peoples' returners?

@Oloremo
Copy link

Oloremo commented Aug 13, 2020

Should this also cover "internal" sub-states? There are a few states that call file.managed internally, for example.

Yeah, we wrote an abomination of the state that calls for 4 different states and we have to play around this very hard to be able to return correct results.

@Akm0d
Copy link
Contributor Author

Akm0d commented Aug 13, 2020

@OrangeDog The original motivation for this was indeed because of idem and idem-cloud.
The first connections I drew were to Ansiblegate and chef, but for sure, states that call file.managed or other states internally would be able to show the changes made by those individual state calls. So yes, this should cover "internal sub states" thank you for that insight 👍 and I'll update the wording of the SEP to reflect it.

Comment on lines +62 to +77
"sub_state_run": [
{
"changes": {}, # A dictionary describing the changes made in the external state run
"result": None, # The external state run name
"comment": None, # Comment on the external state run
"duration": None, # Optional, the duration in seconds of the external state run
"start_time": None, # Optional, the timestamp of the external state run's start time
"low": {
"name": None, # The name of the state from the external state run
"state": None, # Name of the external state run
"__id__": None, # ID of the external state run
"fun": None, # The Function name from the external state run
},
}
],
}
Copy link
Contributor Author

@Akm0d Akm0d Aug 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a good way for the return data to be formatted? I wanted to pass it through the state low data processing function as regular states. Any thoughts on the implementation here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This talks a lot about the motivation and impact on idem, but what about the regular salt engine?
What are the internal and observable changes to e.g. the ansible states, and would they require e.g. changes to peoples' returners?

By default, they won't see any change. It won't break, but nobody will see anything fancy - it will look exactly how it does today. But if the ansible states/modules are updated to actually return the sub state return data? 🎉 then they would show up.

Basically this proposal is driven by idem, but can benefit anything that takes advantage of returning more structured data.

@Akm0d maybe it would also help to add a sample of the current output, as well as what the output would look like with this change applied - obviously using the default outputter, but perhaps JSON style as well.

@OrangeDog
Copy link

if the ansible states/modules are updated to actually return the sub state return data

Shouldn't part of the implementation plan be to do that then (and everywhere else applicable)? A PoC and an analysis of e.g. whether it's a breaking change.

@Akm0d
Copy link
Contributor Author

Akm0d commented Aug 13, 2020

The PoC has been done with idem. It works and does not appear to be a breaking change. The door would be wide open for sub state returns to be applied everywhere else they would be useful. If the SEP is approved I could certainly open feature requests for sub state returns to be used in the ansiblegate state and all the other places it would be useful 👍

@OrangeDog
Copy link

The PoC has been done with idem. It works and does not appear to be a breaking change.

Yes, but I'm asking about the main salt engine, not idem.

@waynew
Copy link
Contributor

waynew commented Aug 14, 2020

if the ansible states/modules are updated to actually return the sub state return data

Shouldn't part of the implementation plan be to do that then (and everywhere else applicable)? A PoC and an analysis of e.g. whether it's a breaking change.

It's probably worthwhile doing a PoC with Ansible/etc. to confirm whether or not they can take advantage of these changes, and whether or not doing that would be a breaking change, though by adding return data I'm not sure how it would be -- unless one is depending on the absence of keys in the return, which seems like a bad idea 😬

But I don't agree that this SEP/feature should require that anything uses it, it should just make the functionality available -- and as you mentioned it shouldn't require breaking changes (unless absolutely necessary).

@waynew
Copy link
Contributor

waynew commented Aug 31, 2020

@Akm0d btw apparently I didn't let you know - this is SEP 24, feel free to update your file!

@waynew waynew changed the title add sub_state_return sep [SEP 24] - add sub_state_return sep Aug 31, 2020
@waynew waynew changed the title [SEP 24] - add sub_state_return sep SEP 24: Add sub_state_return Aug 31, 2020
@waynew waynew mentioned this pull request Aug 31, 2020
3 tasks
@sagetherage sagetherage added Draft Initial Status Final Comment Period Speak now or forever hold your peace. Accepted and removed Draft Initial Status Final Comment Period Speak now or forever hold your peace. labels Feb 5, 2021
@sagetherage sagetherage merged commit 38e5d7c into saltstack:master Feb 11, 2021
@welcome
Copy link

welcome bot commented Feb 11, 2021

Congratulations on your first PR being merged! 🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants