Skip to content
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

New Resource: azurerm_compute_fleet #28758

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sinbai
Copy link
Contributor

@sinbai sinbai commented Feb 12, 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

API: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/azurefleet/resource-manager/Microsoft.AzureFleet/stable/2024-11-01/azurefleet.json

Doc: https://learn.microsoft.com/en-us/azure/azure-compute-fleet/overview

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)

PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromSharedImageGalleryVersion (1674.34s)
PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromSharedImageGallery (1618.08s)
PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromCommunitySharedImageGalleryVersion (1720.16s)
PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromCommunitySharedImageGallery (1772.22s)
PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromImageId (688.07s)
PASS: TestAccComputeFleet_virtualMachineProfileImage_imageFromImageSourceReference (583.79s)
PASS: TestAccComputeFleet_virtualMachineProfileExtensions_complete (238.23s)
PASS: TestAccComputeFleet_virtualMachineProfileExtensions_protectedSettingsFromKeyVault (768.25s)
PASS: TestAccComputeFleet_virtualMachineProfileExtensions_basic (233.85s)
PASS: TestAccComputeFleet_virtualMachineProfileExtensions_update (548.34s)
PASS: TestAccComputeFleet_virtualMachineProfileAuth_authMultipleSSHPublicKeys (616.67s)
PASS: TestAccComputeFleet_virtualMachineProfileAuth_authSSHKey (612.78s)
PASS: TestAccComputeFleet_virtualMachineProfileAuth_authPassword (491.86s)
PASS: TestAccComputeFleet_virtualMachineProfileAuth_authEd25519SSHPublicKeys (446.14s)
PASS: TestAccComputeFleet_virtualMachineProfileAuth_authSSHKeyAndPassword (433.36s)
PASS: TestAccComputeFleet_completeExceptVMSS (323.73s)
PASS: TestAccComputeFleet_update (503.19s)
PASS: TestAccComputeFleet_requiresImport (304.98s)
PASS: TestAccComputeFleet_basic (276.35s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_UserData (544.01s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_scheduledEvent (550.24s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_licenseType (560.89s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_bootDiagnosticEnabled (537.74s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_galleryApplication (1636.13s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_securityProfile (409.62s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_additionalCapabilitiesHibernation (359.61s)
PASS: TestAccComputeFleet_virtualMachineProfileOthers_additionalCapabilitiesUltraSSD (357.57s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_windowsUpdate (774.72s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_windowsComplete (623.81s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_linuxBasic (322.43s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_linuxUpdate (1631.18s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_windowsBasic (360.23s)
PASS: TestAccComputeFleet_virtualMachineProfileOsProfile_linuxComplete (532.94s)
PASS: TestAccComputeFleet_virtualMachineProfileOsDisk_complete (536.28s)
PASS: TestAccComputeFleet_virtualMachineProfileOsDisk_update (1235.23s)
PASS: TestAccComputeFleet_virtualMachineProfileOsDisk_basic (330.43s)
PASS: TestAccComputeFleet_virtualMachineProfileNetwork_basic (379.29s)
PASS: TestAccComputeFleet_virtualMachineProfileNetwork_updateForBaseVirtualMachineProfile (1878.72s)
PASS: TestAccComputeFleet_virtualMachineProfileNetwork_updateForAdditionalLocation (2297.68s)
PASS: TestAccComputeFleet_virtualMachineProfileNetwork_completeForBaseVirtualMachineProfile (836.75s)
PASS: TestAccComputeFleet_virtualMachineProfileNetwork_completeForAdditionalLocation (848.91s)
PASS: TestAccComputeFleet_virtualMachineProfileDataDisk_basic (360.75s)
PASS: TestAccComputeFleet_virtualMachineProfileDataDisk_complete (469.06s)
PASS: TestAccComputeFleet_virtualMachineProfileDataDisk_update (1296.47s)

Change Log

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

  • azurerm_compute_fleet - new resource

This is a (please select all that apply):

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

Copy link
Contributor

@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 @sinbai ,

Thanks for this PR - I've taken a look through and left some comments. If we can fix those up, this should be good to go 👍

ForceNew: true,
},

"vm_attributes": vmAttributesSchema(),
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we define the schema inline as it's not reused in other places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Optional: true,
ForceNew: true,
Default: string(fleets.RegularPriorityAllocationStrategyLowestPrice),
ValidateFunc: validation.StringInSlice([]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a PossibleValuesFor... method for this enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Optional: true,
ForceNew: true,
Default: string(fleets.SpotAllocationStrategyPriceCapacityOptimized),
ValidateFunc: validation.StringInSlice([]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a PossibleValuesFor... method for this enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Optional: true,
ForceNew: true,
Default: string(fleets.EvictionPolicyDelete),
ValidateFunc: validation.StringInSlice([]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a PossibleValuesFor... method for this enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

}
}

if a := model.AdditionalLocationProfile; len(a) > 0 && len(a[0].VirtualMachineProfileOverride) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if a := model.AdditionalLocationProfile; len(a) > 0 && len(a[0].VirtualMachineProfileOverride) > 0 {
if additionalLocationProfile := model.AdditionalLocationProfile; len(additionalLocationProfile) > 0 && len(additionalLocationProfile[0].VirtualMachineProfileOverride) > 0 {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


* `additional_unattend_content` - (Optional) One or more `additional_unattend_content` blocks as defined above.

* `automatic_updates_enabled` - (Optional) Should the automatic updates of the virtual machines be enabled? Defaults to `true`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `automatic_updates_enabled` - (Optional) Should the automatic updates of the virtual machines be enabled? Defaults to `true`.
* `automatic_updates_enabled` - (Optional) Whether to enable the automatic updates of the virtual machines. Defaults to `true`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


* `automatic_updates_enabled` - (Optional) Should the automatic updates of the virtual machines be enabled? Defaults to `true`.

* `bypass_platform_safety_checks_enabled` - (Optional) Should the customer to schedule patching without accidental upgrades be enabled? Defaults to `false`.
Copy link
Contributor

Choose a reason for hiding this comment

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

same as linux_configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


* `bypass_platform_safety_checks_enabled` - (Optional) Should the customer to schedule patching without accidental upgrades be enabled? Defaults to `false`.

* `hot_patching_enabled` - (Optional) Should the customers to patch the virtual machines without requiring a reboot be enabled? Defaults to `false`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `hot_patching_enabled` - (Optional) Should the customers to patch the virtual machines without requiring a reboot be enabled? Defaults to `false`.
* `hot_patching_enabled` - (Optional) Whether to enable the customers to patch the virtual machines without requiring a reboot. Defaults to `false`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


* `patch_mode` - (Optional) Specifies the mode of in-guest patching of the virtual machines. Possible values are `AutomaticByOS`, `AutomaticByPlatform` and `Manual`.

* `provision_vm_agent_enabled` - (Optional) Should the virtual machine agent be provisioned on each virtual machine in the Scale Set? Defaults to `true`.
Copy link
Contributor

Choose a reason for hiding this comment

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

same as linux_configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


* `time_zone` - (Optional) Specifies the time zone of the windows virtual machine. Changing this forces a new resource to be created.

* `vm_agent_platform_updates_enabled` - (Optional) Should the virtual machine agent platform updates be enabled for the windows virtual machine? Defaults to `false`.
Copy link
Contributor

Choose a reason for hiding this comment

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

same as linux_configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@sinbai
Copy link
Contributor Author

sinbai commented Feb 21, 2025

Hi @sinbai ,

Thanks for this PR - I've taken a look through and left some comments. If we can fix those up, this should be good to go 👍

Hi @ms-zhenhua thank you very much for your feedback. I have updated the code, could you please take another look?

@sinbai sinbai force-pushed the computefleet/new_resource branch from 3e24366 to 5f293b9 Compare February 26, 2025 06:46
Copy link
Contributor

@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 @sinbai,

Thank you for the updates. Only one comment left. Others LGTM~

@@ -890,29 +876,31 @@ func (r ComputeFleetResource) Update() sdk.ResourceFunc {

// API requires `osProfile.adminPassword` when updating resource but the GET API does not return the sensitive data `osProfile.adminPassword`
if props := properties.Properties; props != nil {
if len(model.VirtualMachineProfile[0].OsProfile[0].LinuxConfiguration) > 0 {
if v := props.ComputeProfile.BaseVirtualMachineProfile.OsProfile; v != nil {
if v := props.ComputeProfile.BaseVirtualMachineProfile.OsProfile; v != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

what if ComputeProfile == nil or BaseVirtualMachineProfile == nil ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ComputeProfile and BaseVirtualMachineProfile are not pointer types, so I assume they will not be equal to nil.

@sinbai
Copy link
Contributor Author

sinbai commented Feb 28, 2025

Hi @sinbai,

Thank you for the updates. Only one comment left. Others LGTM~

Hi @ms-zhenhua thanks for you time and feedback. Could you please take another look?

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.

2 participants