Skip to content

azurerm_kubernetes_cluster_node_pool - support for the undrainable_node_behavior and max_unavailable properties#30563

Merged
catriona-m merged 19 commits intohashicorp:mainfrom
ms-henglu:branch-250819-aks-upgrade-settings
Nov 7, 2025
Merged

azurerm_kubernetes_cluster_node_pool - support for the undrainable_node_behavior and max_unavailable properties#30563
catriona-m merged 19 commits intohashicorp:mainfrom
ms-henglu:branch-250819-aks-upgrade-settings

Conversation

@ms-henglu
Copy link
Collaborator

@ms-henglu ms-henglu commented Sep 5, 2025

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

This PR adds features in #30515 that are reverted in #30554

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevant documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • azurerm_resource - support for the thing1 property [GH-00000]

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

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.

@ms-henglu ms-henglu marked this pull request as ready for review September 11, 2025 04:26
@ms-henglu ms-henglu requested review from a team, WodansSon and magodo as code owners September 11, 2025 04:26
@ms-henglu
Copy link
Collaborator Author

image

@magodo magodo self-assigned this Sep 16, 2025
magodo
magodo previously requested changes Sep 16, 2025
Copy link
Collaborator

@magodo magodo left a comment

Choose a reason for hiding this comment

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

Thanks for this PR!
I've taken a look through and left some comments inline, but this is mostly looking good to me 👍

@@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shall be Optional? Also, this changes the semantic a bit as I assume it is still required when max_unavailable is not specified?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it's Optional.

@ms-henglu
Copy link
Collaborator Author

Thanks @magodo for the code review. I've updated the doc to change it to "Optional"

@alexp-openai
Copy link

Any updates on merging this PR? Look forward to use this.

@magodo
Copy link
Collaborator

magodo commented Sep 26, 2025

Thanks @ms-henglu! This LGTM now!

@alexp-openai
Copy link

gentle bump on merging/shipping it :) Looks like PR is still stuck in "requested changes" state.

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

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
@ms-henglu
Copy link
Collaborator Author

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.

Got it, I've updated this PR as suggested.

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.

I'll open another PR and share it shortly.

@ms-henglu
Copy link
Collaborator Author

image

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes @ms-henglu, I left a couple more comments inline but this is nearly good to go. Thanks!

Comment on lines +313 to +315
* `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.
Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it.

return old != 0 && new == 0
}),

func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error {
Copy link
Member

Choose a reason for hiding this comment

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

could we remove this now that only one of max_surge and max_unavailable is allowed by the schema?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure.

- 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
@ms-henglu
Copy link
Collaborator Author

Thanks @catriona-m for the code review. I've updated this PR, please check. Thanks!

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

Thanks @ms-henglu, just one last note on the tests, apologies for missing this previously.

},
data.ImportStep(),
{
Config: r.upgradeSettingsMaxUnavailable(data, `50%`, 15, 8),
Copy link
Member

Choose a reason for hiding this comment

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

could we add an additional step where we remove all the optional properties in upgrade settings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a step to remove the optional properties, but some of them can't be removed because

// The behaviour of the API requires this, but this could be removed when https://github.com/Azure/azure-rest-api-specs/issues/27373 has been addressed
pluginsdk.ForceNewIfChange("upgrade_settings.0.drain_timeout_in_minutes", func(ctx context.Context, old, new, meta interface{}) bool {
return old != 0 && new == 0
}),
),

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

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 {
Copy link
Member

Choose a reason for hiding this comment

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

should we move this to kubernetes_nodepool.go since this is no longer used in this file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

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 {
Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure. I also checked the kubernetes_cluster, it's also applicable, I made the same changes.

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this up @ms-henglu, LGTM!

@catriona-m catriona-m dismissed magodo’s stale review November 7, 2025 12:51

comments addressed

@catriona-m catriona-m merged commit eab30fa into hashicorp:main Nov 7, 2025
35 checks passed
@github-actions github-actions bot added this to the v4.53.0 milestone Nov 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants