-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
Add support for overridding whether resources are enabled #5506
Conversation
Supports pack.yaml files in /opt/stackstorm/configs/overrides of following format: --- actions: defaults: enabled: false exceptions: delete_row: enabled: true
Ready for review now, some points:
|
"enabled", | ||
] | ||
|
||
def override(self, pack_name, type, content): |
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.
Would it be better to avoid hijacking the type
keyword and use resource_type
instead?
Good stuff! One concern though as I'm looking at the https://docs.stackstorm.com/reference/pack_configs.html, when the entire pack config is expected to be located in the Logically, With a single config, the advantage seems to me is the design consistency, as we won't need to introduce a new configuration structure Talking about the tradeoffs, do you see any advantages with the |
While it might appear to make sense to have overrides mixed in with the pack config, overrides are both pack config and individual unit config. They are not well defined which makes them a poor fit in the
As stated above, overrides are specific to a unit (action/rule/sensor) and should not be part of pack config. Overriding unit config can change often as the pack evolves or override needs change with the environment St2 is running in. This article https://www.redhat.com/sysadmin/etc-configuration-directories sums up the approach of having separate config files which the same principles apply to packs. Even St2 packs use separate metadata file per unit rather than a single metadata for all units.
To summarise: Overrides should not be mixed with pack config data. They should at least be in a separate directory from config data to avoid name collision: |
I think its clearer to have overrides separate to config (the directory can be created by the st2-package install - so shouldn't affect any of the deployers - so I don't think there is a problem with needing to change installers). But I think Carlos explanation is really good. Maybe cleaner to move up to /opt/stackstorm/overrides rather than under configs/overrides - might be even more clearer to users then? |
Good points @nzlosh, I'm good as long as we have a good reasoning behind it and consider the corner cases there 👍 Would appreciate more 👀 from the @StackStorm/maintainers and @StackStorm/contributors around the feature, syntax, and new functionality in general. |
👍 Prior art / maybe something to provide inspiration hereThe About enabling/disabling rules/actions/other resources. I needed to enable/disable rules based on which instance of stackstorm our packs gets installed in. eg no rules in dev, and only datacenter-relevant rules in prod instances. I made a copy of the relevant actions so I could post them here: https://github.com/cognifloyd/st2-pack-lifecycle The format is similar to the proposed <webui_base_url_hostname>:
<resource_type>:
- <resource_ref>
Here's an example: st2.example.com:
rules:
- autoremediation.disk.foobar One downside to this approach is that it would not work for packs on the exchange. So, admins still need a way to do configure those packs per installation without modifying the packs. Also, it only handles enabling resources assuming that they will be disabled by default. Anywho these are some ideas - maybe pieces could be useful to reuse here. |
Some discussions from TSC:
|
Pack configs has the following structure: @punkrokk If we create the dedicated dir for pack in |
Here is the explanation of how splunk does things: |
Looks like Splunk uses the following override structure:
That's very different from what we have in st2 considering how pack defaults already shipped by content creators, but an interesting perspective to know. Thanks for sharing. |
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.
A few ntipicks, but otherwise, I like it :)
|
||
override_dir = os.path.join(cfg.CONF.system.base_path, "overrides") | ||
# Apply global overrides | ||
global_file = os.path.join(override_dir, "global.yaml") |
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.
I wonder if we should do something during pack install to make sure the pack name is not global
so people don't shoot themselves in the foot.
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.
💯 Nice find of the corner case
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.
@cognifloyd I'll take a look at how best to do that, the alternative is to make the global something we can't use as a packname...
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.
Nice work 👍
We'll also need to pre-create the override
dir via packaging.
Here's an example for configs
: https://github.com/StackStorm/st2-packages/search?q=configs
Co-authored-by: Jacob Floyd <[email protected]>
@armab and @cognifloyd I've added code to prevent pack names that match the reserved pack name list - currently only holds "global" (st2common/st2common/util/pack.py being the main change for that). Also updated the doc PR in the upgrade notes and pack development to say "global" is reserved, and cannot be used for pack names. See StackStorm/st2docs#1109. Packnames can contain _ - so if we wanted we could use _global.yml if preferred? Let us know if that addresses the good spot from @cognifloyd, and any other comments/improvements we might need. |
Ooh. I like |
Same here, |
@armab @cognifloyd Renamed, any further thoughts or inputs we want to get on override feature? So to summarise /opt/stackstorm/overrides/_global.yaml is where the global override goes to, and packs go to /opt/stackstorm/overrides/packname.yaml. _global - is now treated as a reserved name, and not to be used as a pack name. |
I'll merge this and the docs PR once we're satisfied with the docs. 😄 If anyone has additional feedback for this PR, now's the time to add it 😉 |
If anyone finds anything they'd like to change here, please add a follow-up PR or issue. |
Add support to override the enabled setting for actions, aliases, rules, sensors.
Order of loading of settings is:
<pack>.yaml
<pack>.yaml
Looks for override config in /opt/stackstorm/configs/overrides directory (subsequent PR to get this directory created with base examples files in st2-package will be required).
Example files:
/opt/stackstorm/configs/overrides/global.yaml
to disable all sensors and aliases/opt/stackstorm/configs/overrides/<packname>.yaml
to disable all actions exception for .delete_rowOverrides for packs are only specified in the pack.yaml as did not want to add to global.yaml as then there are two places to potentially configure the same type of override.
Could be extended in future to allow overriding of other metadata, but limiting to enabled parameter to start.
Resolves #3973