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

Make instances optional since the API doesn't require this parameter. #17836

Merged
merged 1 commit into from
Aug 2, 2022

Conversation

lonegunmanb
Copy link
Contributor

Make instances optional since the API doesn't require this parameter.
If we leave this parameter nil in creation, the API will respond 0 when we read, so I add a default value to this argument.
This pr will fix #17821 .

The new added acc test:

=== RUN TestAccLinuxVirtualMachineScaleSet_defaultInstanceCount
=== PAUSE TestAccLinuxVirtualMachineScaleSet_defaultInstanceCount
=== CONT TestAccLinuxVirtualMachineScaleSet_defaultInstanceCount
--- PASS: TestAccLinuxVirtualMachineScaleSet_defaultInstanceCount (306.18s)
PASS

If we leave this parameter `nil` in creation, the API will respond `0` when we read, so I add a default value to this argument.
Copy link
Member

@stephybun stephybun 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 @lonegunmanb, LGTM 🥮

@stephybun stephybun merged commit d98612f into hashicorp:main Aug 2, 2022
@github-actions github-actions bot added this to the v3.17.0 milestone Aug 2, 2022
stephybun added a commit that referenced this pull request Aug 2, 2022
@hui-dai
Copy link

hui-dai commented Aug 2, 2022

Thank you for addressing this.

If "instances" is not set, it defaults to 0.

Will pluginsdk.ResourceData.HasChange("instances") return false in this case when checking the diff between "state" and "diff"?

@lonegunmanb
Copy link
Contributor Author

Thank you for addressing this.

If "instances" is not set, it defaults to 0.

Will pluginsdk.ResourceData.HasChange("instances") return false in this case when checking the diff between "state" and "diff"?

Hi @hui-dai , no diff will be addressed in the plan, the acc test will apply a config file without setting instances, then execute plan to make sure that the config is idempotent.

@github-actions
Copy link

github-actions bot commented Aug 5, 2022

This functionality has been released in v3.17.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@hui-dai
Copy link

hui-dai commented Aug 14, 2022

This PR does indeed make the instance parameter optional but it does not appear to have addressed the intent of the request in #17821, which is not to change the number of existing instances during an update action.

The semantics for not setting instances parameter need to be different for
resourceLinuxVirtualMachineScaleSetCreate
Intent: when instances is not set, default to 0
vs
resourceLinuxVirtualMachineScaleSetUpdate
intent: when instances is not set, default to null (Do not set the capacity for the SKU in the API call, see: https://docs.microsoft.com/en-us/rest/api/compute/virtual-machine-scale-sets/create-or-update?tabs=HTTP#sku)

By defaulting to 0, instead of null, this will resize VMSS down to 0 if the instance parameter is not specified.

@github-actions
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 Sep 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants