-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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_service_plan
- support premium service plan auto scale feature
#28524
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @xiaxyi, this overall looks good but there are a few things I've called out. Mainly that there is duplicate checks curing Create/Update that should be caught by the CustomizeDiff. Did you see something that required those checks to be run at plan and apply time?
Also I'm seeing a test failure
=== CONT TestAccServicePlan_linuxPremiumAutoScaleFeatureUpdate
testcase.go:173: Step 4/9 error: Error running apply: exit status 1
Error: `maximum_elastic_worker_count` can only be specified with Elastic Premium Skus
with azurerm_service_plan.test,
on terraform_plugin_test.tf line 40, in resource "azurerm_service_plan" "test":
40: resource "azurerm_service_plan" "test" {
`maximum_elastic_worker_count` can only be specified with Elastic Premium
Skus
--- FAIL: TestAccServicePlan_linuxPremiumAutoScaleFeatureUpdate (235.71s)```
@@ -191,9 +200,19 @@ func (r ServicePlanResource) Create() sdk.ResourceFunc { | |||
} | |||
} | |||
|
|||
if servicePlan.PremiumPlanAutoScaleEnabled { | |||
if !helpers.PlanIsPremium(&servicePlan.Sku) { | |||
return fmt.Errorf("`premium_plan_auto_scale_enabled` can only be set for premium app service plan") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a duplicate of what is in the CustomizeDiff
if servicePlan.MaximumElasticWorkerCount > 0 { | ||
if !isServicePlanSupportScaleOut(servicePlan.Sku) { | ||
return fmt.Errorf("`maximum_elastic_worker_count` can only be specified with Elastic Premium Skus") | ||
if helpers.PlanIsPremium(&servicePlan.Sku) && !servicePlan.PremiumPlanAutoScaleEnabled { | ||
return fmt.Errorf("`maximum_elastic_worker_count` can only be specified with Elastic Premium Skus or Premium Skus that has `premium_plan_auto_scale_enabled` set to `true`") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a duplicate of what is already in the CustomizeDiff. Do we need this check twice?
@@ -88,6 +94,19 @@ func PlanIsConsumption(input *string) bool { | |||
return false | |||
} | |||
|
|||
func PlanIsPremium(input *string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to pass a pointer to a string for this function? It looks like every time we call this function, you're passing in the address of a string when we could just pass the string
func PlanIsPremium(input *string) bool { | |
func PlanIsPremium(input string) bool { |
@@ -341,6 +364,14 @@ func (r ServicePlanResource) Update() sdk.ResourceFunc { | |||
model.Sku.Capacity = pointer.To(state.WorkerCount) | |||
} | |||
|
|||
if metadata.ResourceData.HasChange("premium_plan_auto_scale_enabled") { | |||
if !helpers.PlanIsPremium(&state.Sku) { | |||
return fmt.Errorf("`premium_plan_auto_scale_enabled` can only be set for premium app service plan") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also seems like a duplicate of the CustomizeDiff
@@ -55,7 +55,9 @@ The following arguments are supported: | |||
|
|||
~> **NOTE:** Requires an Isolated SKU. Use one of `I1`, `I2`, `I3` for `azurerm_app_service_environment`, or `I1v2`, `I2v2`, `I3v2` for `azurerm_app_service_environment_v3` | |||
|
|||
* `maximum_elastic_worker_count` - (Optional) The maximum number of workers to use in an Elastic SKU Plan. Cannot be set unless using an Elastic SKU. | |||
* `premium_plan_auto_scale_enabled` - (Optional) Should automatic scaling be enabled for the Premium SKU Plan. Defaults to `false`.Cannot be set unless using a Premium SKU. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `premium_plan_auto_scale_enabled` - (Optional) Should automatic scaling be enabled for the Premium SKU Plan. Defaults to `false`.Cannot be set unless using a Premium SKU. | |
* `premium_plan_auto_scale_enabled` - (Optional) Should automatic scaling be enabled for the Premium SKU Plan. Defaults to `false`. Cannot be set unless using a Premium SKU. |
@mbfrahry Thanks for the comments, code is updated and tests are passed. The failed tests are irrelevant to the code change. |
Community Note
Description
PR Checklist
For example: “
resource_name_here
- description of change e.g. adding propertynew_property_name_here
”Changes to existing Resource / Data Source
Testing
--- PASS: TestAccServicePlan_completeUpdate (223.57s)
--- PASS: TestAccServicePlan_completeUpdate (223.57s)
--- PASS: TestAccServicePlan_completeUpdate (223.57s)
--- PASS: TestAccServicePlan_maxElasticWorkerCount (230.74s)
--- PASS: TestAccServicePlan_basic (128.02s)
--- PASS: TestAccServicePlan_requiresImport (108.08s)
--- PASS: TestAccServicePlan_linuxFlexConsumption (111.20s)
--- PASS: TestAccServicePlan_linuxConsumption (119.28s)
--- PASS: TestAccServicePlan_linuxPremiumAutoScaleFeatureUpdate (311.50s)
--- PASS: TestAccServicePlanIsolated_appServiceEnvironmentV3 (4023.99s)
FAIL
Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_service_plan
- support for thepremium_plan_auto_scale_enabled
property [[azurerm_service_plan] Support for the new Automatic Scaling (currently in preview) #22313]This is a (please select all that apply):
Related Issue(s)
Fixes #22313
Fixes #28358
Note
If this PR changes meaningfully during the course of review please update the title and description as required.