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

Add 'priority' property for VM scale set #1250

Merged
merged 1 commit into from
May 24, 2018

Conversation

CoRfr
Copy link
Contributor

@CoRfr CoRfr commented May 17, 2018

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

@katbyte katbyte self-requested a review May 18, 2018 02:41
Copy link
Collaborator

@katbyte katbyte left a 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)
Copy link
Collaborator

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!

Copy link
Contributor Author

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"),
Copy link
Collaborator

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.

@katbyte katbyte added enhancement service/vmss Virtual Machine Scale Sets labels May 19, 2018
@katbyte katbyte added this to the 1.6.0 milestone May 19, 2018
@CoRfr CoRfr force-pushed the lowpriorityscalesets branch from 4f2a5ef to eac4932 Compare May 22, 2018 20:49
@CoRfr
Copy link
Contributor Author

CoRfr commented May 22, 2018

@katbyte I updated the test and also rebased.

Copy link
Collaborator

@katbyte katbyte left a 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 {
Copy link
Collaborator

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.

Copy link
Contributor Author

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,
},
Copy link
Collaborator

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"),
Copy link
Collaborator

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,
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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
@CoRfr CoRfr force-pushed the lowpriorityscalesets branch from eac4932 to 3860a2e Compare May 24, 2018 07:23
Copy link
Collaborator

@katbyte katbyte left a 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

@katbyte
Copy link
Collaborator

katbyte commented May 24, 2018

tests pass (with 2 known failures)
screen shot 2018-05-24 at 09 34 57

Thank you for the contribution @CoRfr 🙂

@katbyte katbyte merged commit a2ea8a0 into hashicorp:master May 24, 2018
katbyte added a commit that referenced this pull request May 24, 2018
@ghost
Copy link

ghost commented Mar 31, 2020

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!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement service/vmss Virtual Machine Scale Sets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants