-
Notifications
You must be signed in to change notification settings - Fork 48
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
Migrate Rule module to new API #572
Conversation
@msekania: You already spent a lot of time diving into the rule module and its flaws. Can you have a look at my completely rewritten rule module and test it, if you have some time? |
I've gone through the code and have more than a few suggestions for improvement and cleanup. I'll do the code review comments right after. As for the rest, overwriting, it's good overall, but I don't like that the functionality has been reduced compared to the existing version. Namely, the check whether a rule already exists no longer takes place if rule_id is not specified. I understand that the existing version was not perfect in this regard, but it was still useful and all my use cases relied on this functionality. Currently there is also no way to compensate the "removed" functionality with the lookup rule plugin. I am currently working to bring that functionality back, if you do not mind. |
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 cannot make any changes to this branch otherwise I could apply the changes directly or via merge request
plugins/modules/rule.py
Outdated
def modify_rule(module, base_url, headers, ruleset, rule): | ||
changed = True | ||
rule_id = rule.get("rule_id") | ||
desired_location = desired.get("rule", {}).get("location") |
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 think, this should read
desired_location = desired.get("location")
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 don't think so. "location" is a parameter inside of the rule, not a top level one.
Hi @msekania Thanks a lot for your comprehensive review!
I know that my changes are breaking existing stuff. I decided to do that, because the current module is kind of unreliable and unpredictable in its behavior, and so I wanted to move the module and its use cases to the direction of how the API is intended to be used. I will discuss with my colleagues if we might bring back the previous behavior at least as a side-feature. Best regards |
Hi @lgetwan, General problem which I have with a new version (without modification) is that that one creates all the time the same rule, because there is no any mechanisms that allows to check and stop recreation of the same rule again and again. I would appreciate if one would have a mechanism to try to deduce the rule_id if user is not providing it from the rest of parameters. Positioning in folder issues one can solve by introducing extra position value "any" in addition to "top", "bottom", "before", and "after", which will ignore precise position check within folder in I have finished implementation of this features, and it's more or less like what I would like to have. I also found some extra bugs in current version. In which form I should provide the changes? Best regards, |
Add Improvements to: Migrate Rule module to new API
I will check that tomorrow. |
The last commit solves the problem for 2.2.0, but I still don't get why it doesn't work for 2.3.0... |
@robin-checkmk & @msekania, |
there are some more improvements see #602 , I could not test 2.3.0 yet, but similar fixes might be due for 2.3.0 as well. I also have a question concerning your last changes. |
I have an Idea how to incorporate logic of your changes in what I wrote above. I'll need hour or two at most. |
…module_improved_idempotency
…roved_idempotency Migrate Rule Module: Improved Idempotency
I really love solution with I have tested with 2.2.0 and it works for all my rules too. |
I can confirm ~85% idempotency as well for 2.2 and 2.3. The only challenges that remain from my point of view are:
|
I migrated the rule module to the new API and made it a bit nicer.
Will update this description soon. Just wanted to save my work before the weekend. ;-)
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Rule module is a bit ugly and only ~23% idempotent.
What is the new behavior?
Rule module
Other information
100% idempotency will be reached, once the value_raw is handled differently by Checkmk and its REST API.