-
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
Add 'priority' property for VM scale set #1250
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.
Hello @CoRfr,
Thank you for adding this property! It LGTM aside from one minor comment on the test. Once that is fixed up i look forward to getting this merged 🙂
@@ -820,7 +854,7 @@ func testCheckAzureRMVirtualMachineScaleSetSinglePlacementGroup(name string, exp | |||
} | |||
|
|||
if *resp.SinglePlacementGroup != expectedSinglePlacementGroup { | |||
return fmt.Errorf("Bad: Overprovision should have been %t for scale set %v", expectedSinglePlacementGroup, name) | |||
return fmt.Errorf("Bad: SinglePlacementGroup should have been %t for scale set %v", expectedSinglePlacementGroup, name) |
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.
Thank you for fixing this too!
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.
NP!
Config: config, | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMVirtualMachineScaleSetExists("azurerm_virtual_machine_scale_set.test"), | ||
testCheckAzureRMVirtualMachineScaleSetPriority("azurerm_virtual_machine_scale_set.test", "Low"), |
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.
Unless there is a reason for us to query Azure directly could we change this to check the state? like:
resource.TestCheckResourceAttr(resourceName, "azurerm_virtual_machine_scale_set.test. priority", "low"),
I know this isn't like many of the tests in the resource, but without good reason this is how we should be verifying the new property as it also checks the state.
4f2a5ef
to
eac4932
Compare
@katbyte I updated the test and also rebased. |
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 @CoRfr,
Thanks for the timely changes. Re-reviewed and left some comment inline. It looks like you left in the old test function.
Also could we update the documentation to reflect the new property?
@@ -812,6 +829,21 @@ func testCheckAzureRMVirtualMachineScaleSetOverprovision(name string) resource.T | |||
} | |||
} | |||
|
|||
func testCheckAzureRMVirtualMachineScaleSetPriority(name string, expectedPriority string) resource.TestCheckFunc { |
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.
I think you forgot to remove this.
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.
Oops, removed.
"priority": { | ||
Type: schema.TypeString, | ||
Optional: 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.
Is this possible to validate against the VirtualMachinePriorityTypes
enum?
Steps: []resource.TestStep{ | ||
{ | ||
Config: config, | ||
Check: resource.TestCheckResourceAttr(resourceName, "priority", "Low"), |
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.
could we also check that the resource exists:
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualMachineExists(resourceName, &afterCreate),
resource.TestCheckResourceAttr(resourceName, "priority", "Low"),
),
@@ -115,6 +115,11 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource { | |||
ForceNew: true, | |||
}, | |||
|
|||
"priority": { | |||
Type: schema.TypeString, | |||
Optional: 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.
could we add "ForceNew" here since a scale set cannot have a mix of Low and Regular VM. Unless Azure will update all pre-existing VM if you change your scaleset from Regular
to Low
?
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.
Seems like we would need a new scale set, so added ForceNew as suggested.
} | ||
} | ||
|
||
`, rInt, location, rInt, rInt, rInt, rInt, rInt) |
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.
can we reuse the first rInt
using %[1]d
, I cleaned up all the previous tests in my pending PR
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.
Sounds good, I had a look at https://github.com/terraform-providers/terraform-provider-azurerm/pull/1209/files#diff-62e6c44ba2b5a3617bb9c78744b7a84bR515-R533 and did something similar.
Purpose is to support low-priority VMs, which should partially address hashicorp#1249. This is simply adding a 'priority' parameter that can be set to Low or Regular (=default). The evictionPolicy is not supported yet as it was introduced in a more recent version of the compute API (2018-04-01). Cf https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-use-low-priority
eac4932
to
3860a2e
Compare
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.
@CoRfr, LGTM! 👍 running tests
tests pass (with 2 known failures) Thank you for the contribution @CoRfr 🙂 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Purpose is to support low-priority VMs, which should partially
address #1249.
This is simply adding a 'priority' parameter that can be set
to Low or Regular (=default).
The evictionPolicy is not supported yet as it was introduced
in a more recent version of the compute API (2018-04-01).
Cf https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-use-low-priority