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

azurerm_orchestrated_virtual_machine_scale_set - add sku_profile to support instance mix feature #27599

Merged
merged 3 commits into from
Oct 29, 2024

Conversation

ms-zhenhua
Copy link
Contributor

@ms-zhenhua ms-zhenhua commented Oct 9, 2024

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

MS-DOC

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 relevent 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_orchestrated_virtual_machine_scale_set - add sku_profile to support mix instance feature

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

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

@ms-zhenhua ms-zhenhua changed the title azurerm_orchestrated_virtual_machine_scale_set - add sku_profile to support mix instance feature azurerm_orchestrated_virtual_machine_scale_set - add sku_profile to support instance mix feature Oct 9, 2024
@ms-zhenhua ms-zhenhua marked this pull request as ready for review October 9, 2024 08:31
Copy link
Member

@jackofallops jackofallops 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-zhenhua - Thanks for this PR. A few things to take a look at below. It also looks like there's inconsistency between the schema and the code for the new block, can you take a look?

Thanks

Comment on lines 422 to 423
// currently only supported in EastUS, WestUS, EastUS2, and WestUS2
data.Locations.Primary = "eastus2"
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 update this to be a TODO so we know it needs to be removed when the Preview is rolled out to our normal testing region(s).

Can we get an estimate from the Service team as to when this will be deployed to the normal regions?

Suggested change
// currently only supported in EastUS, WestUS, EastUS2, and WestUS2
data.Locations.Primary = "eastus2"
// TODO - Remove this override when Preview is rolled out to westeurope - currently only supported in EastUS, WestUS, EastUS2, and WestUS2
data.Locations.Primary = "eastus2"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. I am still confirming with the service team when will westeurope be available.

Choose a reason for hiding this comment

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

the current rollout which will take approximately 2 weeks will enable the feature in all regions

Comment on lines 437 to 438
// currently only supported in EastUS, WestUS, EastUS2, and WestUS2
data.Locations.Primary = "eastus2"
Copy link
Member

Choose a reason for hiding this comment

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

As above

Suggested change
// currently only supported in EastUS, WestUS, EastUS2, and WestUS2
data.Locations.Primary = "eastus2"
// TODO - Remove this override when Preview is rolled out to westeurope - currently only supported in EastUS, WestUS, EastUS2, and WestUS2
data.Locations.Primary = "eastus2"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated. thanks.

"sku_profile": {
Type: pluginsdk.TypeList,
Optional: true,
ForceNew: true,
Copy link
Member

Choose a reason for hiding this comment

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

Given this is ForceNew what is the default value here? Are we going to trigger replacements for existing resources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sku_profile can be set only when sku_name="Mix" and it cannot be added/removed through update. However, its sub-properties allocation_strategy and vm_sizes can be changed through Update.

@@ -351,6 +380,14 @@ func resourceOrchestratedVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData,
props.Sku = sku
}

if v, ok := d.GetOk("sku_profile"); ok {
if props.Sku == nil || pointer.From(props.Sku.Name) != "Mix" {
Copy link
Member

Choose a reason for hiding this comment

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

Could this be implemented as a customiseDiff to catch this configuration issue at plan time rather than erroring out here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved the logic into customiseDiff . Thanks.

@@ -351,6 +380,14 @@ func resourceOrchestratedVirtualMachineScaleSetCreate(d *pluginsdk.ResourceData,
props.Sku = sku
}

if v, ok := d.GetOk("sku_profile"); ok {
if props.Sku == nil || pointer.From(props.Sku.Name) != "Mix" {
Copy link
Member

Choose a reason for hiding this comment

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

Also, can we have this ("Mix") defined as a const rather than using magic string everywhere?
maybe:

Suggested change
if props.Sku == nil || pointer.From(props.Sku.Name) != "Mix" {
if props.Sku == nil || pointer.From(props.Sku.Name) != skuNameMix {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

defined it in a const variable. Thanks.

@@ -732,6 +769,11 @@ func resourceOrchestratedVirtualMachineScaleSetUpdate(d *pluginsdk.ResourceData,
}
}

if d.HasChange("sku_profile") {
Copy link
Member

Choose a reason for hiding this comment

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

This block is ForceNew in the schema, why are we checking for updates?

Copy link
Contributor Author

@ms-zhenhua ms-zhenhua Oct 28, 2024

Choose a reason for hiding this comment

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

answered in the above comment. Though it's defined ForceNew, its sub-properties can be changed through Update as long as sku_profile is not removed.

@ms-zhenhua ms-zhenhua requested review from katbyte and a team as code owners October 28, 2024 05:59
@ms-zhenhua
Copy link
Contributor Author

Hi @jackofallops, thank you for your review. I have resolved the comments. For testcases, I will create another PR to remove the region limitation once Azure supports it. Could you please help take another review?

--- PASS: TestAccOrchestratedVirtualMachineScaleSet_skuProfileErrorConfiguration (32.10s)
--- PASS: TestAccOrchestratedVirtualMachineScaleSet_skuProfile (440.99s)
PASS
ok github.com/hashicorp/terraform-provider-azurerm/internal/services/compute 445.475s

Copy link
Member

@jackofallops jackofallops 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-zhenhua - Thanks for making those changes, this LGTM now 👍

@jackofallops
Copy link
Member

Testing looks fine - failures are not related to change:
image

@jackofallops jackofallops merged commit 0af5a37 into hashicorp:main Oct 29, 2024
40 checks passed
@github-actions github-actions bot added this to the v4.8.0 milestone Oct 29, 2024
jackofallops added a commit that referenced this pull request Oct 29, 2024
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2024
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.

4 participants