azurerm_kubernetes_cluster_node_pool - support for the undrainable_node_behavior and max_unavailable properties#30563
Conversation
…- support for the `undrainable_node_behavior` and `max_unavailable` properties
magodo
left a comment
There was a problem hiding this comment.
Thanks for this PR!
I've taken a look through and left some comments inline, but this is mostly looking good to me 👍
internal/services/containers/kubernetes_cluster_node_pool_resource.go
Outdated
Show resolved
Hide resolved
| @@ -312,6 +312,12 @@ A `upgrade_settings` block supports the following: | |||
|
|
|||
| * `max_surge` - (Required) The maximum number or percentage of nodes which will be added to the Node Pool size during an upgrade. | |||
There was a problem hiding this comment.
This shall be Optional? Also, this changes the semantic a bit as I assume it is still required when max_unavailable is not specified?
There was a problem hiding this comment.
Yes, it's Optional.
|
Thanks @magodo for the code review. I've updated the doc to change it to "Optional" |
|
Any updates on merging this PR? Look forward to use this. |
|
Thanks @ms-henglu! This LGTM now! |
|
gentle bump on merging/shipping it :) Looks like PR is still stuck in "requested changes" state. |
catriona-m
left a comment
There was a problem hiding this comment.
Thanks for giving me more info @ms-henglu . Based on what you've said, I think we should use ExactlyOneOf in the schema to ensure either max_surge or max_unavailable is set and when max_unavailable is set, we should set max_surge to 0 explicitly in the request.
Since the upgrade_settings block is always returned with a default value, we should make this Required in 5.0, however this could be done in a separate pr.
- Add ExactlyOneOf validation for max_surge and max_unavailable fields - Remove Default value "0" from max_unavailable field - Expand function sets opposite field to "0" when one is specified - Flatten function filters out "0" and "0%" values for both fields - Update test to remove explicit max_surge = "0" configuration
Got it, I've updated this PR as suggested.
I'll open another PR and share it shortly. |
catriona-m
left a comment
There was a problem hiding this comment.
Thanks for making the changes @ms-henglu, I left a couple more comments inline but this is nearly good to go. Thanks!
| * `max_surge` - (Optional) The maximum number or percentage of nodes which will be added to the Node Pool size during an upgrade. Exactly one of `max_surge` or `max_unavailable` must be specified. | ||
|
|
||
| * `max_unavailable` - (Optional) The maximum number or percentage of nodes which can be unavailable during the upgrade. Exactly one of `max_surge` or `max_unavailable` must be specified. |
There was a problem hiding this comment.
should we remove Exactly one of max_surgeormax_unavailable must be specified. from the end of these and add it as a note below instead?
| return old != 0 && new == 0 | ||
| }), | ||
|
|
||
| func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error { |
There was a problem hiding this comment.
could we remove this now that only one of max_surge and max_unavailable is allowed by the schema?
- Remove redundant CustomizeDiff validation for max_surge/max_unavailable since ExactlyOneOf constraint in schema already enforces this - Update documentation to use note block instead of repeating constraint in field descriptions for cleaner documentation format
|
Thanks @catriona-m for the code review. I've updated this PR, please check. Thanks! |
catriona-m
left a comment
There was a problem hiding this comment.
Thanks @ms-henglu, just one last note on the tests, apologies for missing this previously.
| }, | ||
| data.ImportStep(), | ||
| { | ||
| Config: r.upgradeSettingsMaxUnavailable(data, `50%`, 15, 8), |
There was a problem hiding this comment.
could we add an additional step where we remove all the optional properties in upgrade settings?
There was a problem hiding this comment.
I added a step to remove the optional properties, but some of them can't be removed because
catriona-m
left a comment
There was a problem hiding this comment.
Thanks @ms-henglu I left a couple more comments for you to consider but hopefully this should be nearly there. Thanks!
| } | ||
| } | ||
|
|
||
| func upgradeSettingsSchemaClusterDefaultNodePool() *pluginsdk.Schema { |
There was a problem hiding this comment.
should we move this to kubernetes_nodepool.go since this is no longer used in this file?
| pluginsdk.ForceNewIfChange("upgrade_settings.0.drain_timeout_in_minutes", func(ctx context.Context, old, new, meta interface{}) bool { | ||
| return old != 0 && new == 0 | ||
| }), | ||
| pluginsdk.ForceNewIfChange("upgrade_settings.0.undrainable_node_behavior", func(ctx context.Context, old, new, meta interface{}) bool { |
There was a problem hiding this comment.
can we add a note in the docs to explain that once added, this property cannot be removed? Also, could you check if this is also applicable to this property in kubernetes_cluster?
There was a problem hiding this comment.
Sure. I also checked the kubernetes_cluster, it's also applicable, I made the same changes.
…grade_settings schema
catriona-m
left a comment
There was a problem hiding this comment.
Thanks for fixing this up @ms-henglu, LGTM!
|
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. |


Community Note
Description
This PR adds features in #30515 that are reverted in #30554
PR Checklist
For example: “
resource_name_here- description of change e.g. adding propertynew_property_name_here”Changes to existing Resource / Data Source
Testing
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_resource- support for thething1property [GH-00000]This is a (please select all that apply):
Related Issue(s)
Fixes #0000
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the provider.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Note
If this PR changes meaningfully during the course of review please update the title and description as required.