Skip to content

new resource azurerm_kubernetes_fleet_auto_upgrade_profile#31941

Open
ms-henglu wants to merge 10 commits intohashicorp:mainfrom
ms-henglu:branch-250311-fleet-auto-upgrade-profile
Open

new resource azurerm_kubernetes_fleet_auto_upgrade_profile#31941
ms-henglu wants to merge 10 commits intohashicorp:mainfrom
ms-henglu:branch-250311-fleet-auto-upgrade-profile

Conversation

@ms-henglu
Copy link
Copy Markdown
Collaborator

@ms-henglu ms-henglu commented Mar 12, 2026

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 a new resource: "azurerm_kubernetes_fleet_auto_upgrade_profile"

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)
image

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

AI Assistance Disclosure

  • AI Assisted - This contribution was made by, or with the assistance of, AI/LLMs

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.

Copy link
Copy Markdown
Collaborator

@liuwuliuyun liuwuliuyun left a comment

Choose a reason for hiding this comment

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

Left some comments~ Thanks

return fmt.Errorf("retrieving existing %s: %+v", *id, err)
}
if existing.Model == nil {
return fmt.Errorf("retrieving existing %s: properties was nil", *id)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Issue: The check is on existing.Model == nil, but the error message says "properties was nil". Per error handling standards, the message should accurately describe what was nil.
Suggested fix: Change to "retrieving existing %s: model was nil"

},

"disabled": {
Optional: true,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Issue: The disabled field is defined in the schema and handled in Create(), Read(), and Update(), but none of the test configurations (basic, complete, update) set disabled. This means the field has zero test coverage. Per testing guidelines, updatable fields should be exercised in the complete and/or update test configs.
Suggested fix: Add disabled = true to the complete config and disabled = false (or remove it) in the update config, so the HasChange("disabled") path is also tested.

Plus, the name of the field could also need reconsideration based on https://github.com/hashicorp/terraform-provider-azurerm/blob/main/contributing/topics/reference-naming.md#boolean-property-naming-conventions


* `update_strategy_id` - (Optional) The ID of the Fleet Update Strategy to use for this auto upgrade profile. Changing this forces a new Kubernetes Fleet Auto Upgrade Profile to be created.

* `disabled` - (Optional) Whether the auto upgrade profile is disabled.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Issue: Per documentation guidelines, Optional arguments should be listed in alphabetical order. Current order: node_image_selection_type, update_strategy_id, disabled. Should be: disabled, node_image_selection_type, update_strategy_id.
Suggested fix: Reorder to alphabetical.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Issue: Per documentation guidelines, Optional boolean fields should document default behavior. Users need to know what happens whendisabledis not set — is the profile enabled by default?

Suggested fix: Add default info, e.g.,Whether the auto upgrade profile is disabled. Defaults to false.` (if that matches the API behavior).


"update_strategy_id": {
Optional: true,
ForceNew: true,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Issue: update_strategy_id is marked ForceNew: true, meaning any change to it will destroy and recreate the resource. The SDK model has UpdateStrategyId *string with json:"updateStrategyId,omitempty", suggesting it's a mutable field in the API. If the Azure API allows updating this field via PUT/CreateOrUpdate without recreation, ForceNew is unnecessarily destructive for users. We might need to verify the API actually requires recreation when changing the update strategy.

Copy link
Copy Markdown
Collaborator

@ms-zhenhua ms-zhenhua left a comment

Choose a reason for hiding this comment

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

Hi @ms-henglu ,

Thanks for this PR - I've taken a look through and left some comments inline.

Optional: true,
ForceNew: true,
Type: pluginsdk.TypeString,
ValidateFunc: fleetupdatestrategies.ValidateUpdateStrategyID,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

shall we use commonschema.ResourceIDReferenceOptionalForceNew(&fleetupdatestrategies.UpdateStrategyId{}) instead?

Comment on lines +175 to +177
provider "azurerm" {
features {}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

provider block should be explicitly defined in each testcase


* `update_strategy_id` - (Optional) The ID of the Fleet Update Strategy to use for this auto upgrade profile. Changing this forces a new Kubernetes Fleet Auto Upgrade Profile to be created.

* `disabled` - (Optional) Whether the auto upgrade profile is disabled.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Booleans named disableSomething in the API should be flipped and exposed as something_enabled in the provider. (ref)

Co-authored-by: Zhenhua Hu <zhhu@microsoft.com>
…down

Co-authored-by: Zhenhua Hu <zhhu@microsoft.com>
@ms-henglu ms-henglu requested a review from ms-zhenhua March 17, 2026 04:44
Copy link
Copy Markdown
Collaborator

@ms-zhenhua ms-zhenhua left a comment

Choose a reason for hiding this comment

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

2 more comments left. Please help confirm.

}
}

payload.Properties.UpdateStrategyId = config.UpdateStrategyId
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could this assignment of UpdateStrategyId be done when initializing payload at line 116?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines +32 to +34
NodeImageSelectionType *string `tfschema:"node_image_selection_type"`
UpdateStrategyId *string `tfschema:"update_strategy_id"`
Enabled *bool `tfschema:"enabled"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why do you define these 3 properties as pointer?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I change the Enabled to bool, the other two doesn't have a default value, so I keep them as pointers, should I fix them?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I change the Enabled to bool, the other two doesn't have a default value, so I keep them as pointers, should I fix them?

- Change Enabled model field from *bool to bool (has Default: true)
- Move UpdateStrategyId and Disabled into payload initialization in Create
- Simplify Update method for non-pointer Enabled
- Change NodeImageSelectionType and UpdateStrategyId from *string to string
- Update Create, Read, and Update methods to use pointer.To/pointer.From
  for SDK field conversion
Copy link
Copy Markdown
Collaborator

@liuwuliuyun liuwuliuyun left a comment

Choose a reason for hiding this comment

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

LGTM now, thanks~

@ms-henglu ms-henglu requested a review from ms-zhenhua March 27, 2026 02:15
Copy link
Copy Markdown
Collaborator

@ms-zhenhua ms-zhenhua left a comment

Choose a reason for hiding this comment

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

LGTM~

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants