-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Support for auto-mitigate for Monitor scheduled query rules alerts #13036 #13213
Conversation
I've incorporated changes from feedback from @Klaas- and I'm ready for another round of review |
I think you can use "ConflictsWith" to ensure that no one sets them both, right? |
"ConflictsWith" is interesting! I was looking at other ressources like application_gateway and they were validating in the update function, but ConflictsWith is the prefered way, right? Is it somewhat new? |
I am not sure, I just started with terraform today :) |
Ah no problem! @katbyte and @tombuildsstuff, what do you think? |
So I tested the way it's currently implemented in this PR. 2nd problem: even if I leave throttling away and I test it I still get |
there is another issue: #12341 that says this will need a new azure go sdk version |
I am not sure where the throttlingInMin must be suppressed when it's zero, would that happen somewhere here: terraform-provider-azurerm/internal/services/monitor/monitor_scheduled_query_rules_alert_resource.go Line 408 in eb2c5e8
or should that be handled here: what I tested is inside the models.go I can just check if it's bigger than 0 and it works as expected. I do not think it still needs a newer go sdk version, as stated in #12341, maybe that's needed for the 1 minute intervals not the statefulness. |
I've done changes according to feedback. I've switched to use ConflictsWith and simplified the Update function. Ideally I would touch as little as possible "throttle" in this PR. I want to help out a coworker that needs "auto_mitigate" as soon as possible. I'm ready for another round of review |
@cloutier did you see #13213 (comment) I think you also need to change something in terraform-provider-azurerm/internal/services/monitor/monitor_scheduled_query_rules_alert_resource.go Line 406 in bf33fce
"throttlingInMin":0
I am not sure if you should change something in azure sdk or here though :) |
@Klaas- Yes I have! This is outside the scope of what I want to do with this PR though |
but without that auto mitigate won't work |
Can you suggest a test scenario that worries you? I can add that |
Thanks for the feedback @katbyte! I've done the changes you suggested. I've added a test for the undocumented quirk that @Klaas- was talking about, but I saw it the logs of the pipeline that it hasn't actually run:
When is that test actually run? Also should I do things locally to run the test or is there a way to run it in this PR verification? |
@cloutier I don't think the PR tests actually do tests on azure, if I understood https://github.com/hashicorp/terraform-provider-azurerm/blob/main/README.md#developing-the-provider correctly you need to run those manually. |
I think I've finally figured a way to not send throttling if it's not set (in the last commit). My question for tests is more: Does it run once upon merges? Or just before releases? Or from time to time? Also another question for @katbyte: The default in this PR is set to true to be consistent with other ressources in this provider, but the default in the api is false. Did I make the right choice? |
internal/services/monitor/monitor_scheduled_query_rules_alert_resource.go
Outdated
Show resolved
Hide resolved
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.
Hi @cloutier, thanks for the previous changes, unfortunately I was still getting test failures. I've left some comments, once those are fixed up the tests should run and then we can merge this 🙂.
internal/services/monitor/monitor_scheduled_query_rules_alert_resource.go
Outdated
Show resolved
Hide resolved
internal/services/monitor/monitor_scheduled_query_rules_alert_resource.go
Outdated
Show resolved
Hide resolved
internal/services/monitor/monitor_scheduled_query_rules_alert_resource.go
Outdated
Show resolved
Hide resolved
internal/services/monitor/monitor_scheduled_query_rules_alert_resource.go
Outdated
Show resolved
Hide resolved
internal/services/monitor/monitor_scheduled_query_rules_alert_resource.go
Outdated
Show resolved
Hide resolved
internal/services/monitor/monitor_scheduled_query_rules_alert_resource_test.go
Outdated
Show resolved
Hide resolved
website/docs/r/monitor_scheduled_query_rules_alert.html.markdown
Outdated
Show resolved
Hide resolved
website/docs/r/monitor_scheduled_query_rules_alert.html.markdown
Outdated
Show resolved
Hide resolved
Co-authored-by: stephybun <[email protected]>
@stephybun Thanks for the feedback! 🙏 You are helping me getting better at Go and Terraform. Thanks also to @Klaas- for the warning about the pitfalls of this API I think I'm ready for the final round of test and review |
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've tested it, it now works and I can switch alerts from suppression to auto mitigation and back, nice work!
Thanks @cloutier - tests are passing 🎆. This LGTM 🥳 |
This functionality has been released in v2.77.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
No description provided.