new resource azurerm_kubernetes_fleet_auto_upgrade_profile#31941
new resource azurerm_kubernetes_fleet_auto_upgrade_profile#31941ms-henglu wants to merge 10 commits intohashicorp:mainfrom
azurerm_kubernetes_fleet_auto_upgrade_profile#31941Conversation
liuwuliuyun
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
ms-zhenhua
left a comment
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
shall we use commonschema.ResourceIDReferenceOptionalForceNew(&fleetupdatestrategies.UpdateStrategyId{}) instead?
website/docs/r/kubernetes_fleet_auto_upgrade_profile.html.markdown
Outdated
Show resolved
Hide resolved
internal/services/containers/kubernetes_fleet_auto_upgrade_profile_resource.go
Outdated
Show resolved
Hide resolved
internal/services/containers/kubernetes_fleet_auto_upgrade_profile_resource_test.go
Outdated
Show resolved
Hide resolved
| provider "azurerm" { | ||
| features {} | ||
| } |
There was a problem hiding this comment.
provider block should be explicitly defined in each testcase
internal/services/containers/kubernetes_fleet_auto_upgrade_profile_resource.go
Outdated
Show resolved
Hide resolved
internal/services/containers/kubernetes_fleet_auto_upgrade_profile_resource.go
Outdated
Show resolved
Hide resolved
internal/services/containers/kubernetes_fleet_auto_upgrade_profile_resource.go
Outdated
Show resolved
Hide resolved
internal/services/containers/kubernetes_fleet_auto_upgrade_profile_resource.go
Outdated
Show resolved
Hide resolved
|
|
||
| * `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. |
There was a problem hiding this comment.
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-zhenhua
left a comment
There was a problem hiding this comment.
2 more comments left. Please help confirm.
| } | ||
| } | ||
|
|
||
| payload.Properties.UpdateStrategyId = config.UpdateStrategyId |
There was a problem hiding this comment.
Could this assignment of UpdateStrategyId be done when initializing payload at line 116?
| NodeImageSelectionType *string `tfschema:"node_image_selection_type"` | ||
| UpdateStrategyId *string `tfschema:"update_strategy_id"` | ||
| Enabled *bool `tfschema:"enabled"` |
There was a problem hiding this comment.
why do you define these 3 properties as pointer?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Community Note
Description
This PR adds a new resource: "azurerm_kubernetes_fleet_auto_upgrade_profile"
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
AI Assistance Disclosure
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.