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 support for Azure LB Standard and Public IP Standard #665

Merged
merged 17 commits into from
Jan 26, 2018

Conversation

justaugustus
Copy link
Contributor

Ref: #579

@justaugustus
Copy link
Contributor Author

@tombuildsstuff would you mind taking a peep at this?

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @justaugustus

Thanks for this PR - I've taken a look through and left some comments in-line but this is off to a good start. From what I can see there's three things missing to be able to merge this:

  1. We need to set the field sku in the Read function like here https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/resource_arm_loadbalancer.go#L181 - we can handle existing LB's without a SKU set via:
if sku := loadBalancer.Sku; sku != nil {
  d.Set("sku", string(sku.Name))
}
  1. We need to add an acceptance test for a Standard SKU Load Balancer - here's how we test the Basic SKU - we should only need to set sku = "standard" since the other scenarios / combinations are tested via the Basic SKU (which is fine for now)

  2. Document the new sku field to mention there's two possible values; we'd tend to make this something similar to:

* `sku` - (Optional) The Name of the SKU to use for this Load Balancer. Accepted values are `Basic` and `Standard`. Defaults to `Basic`

That said - this is off to a good start and I've left some other comments in-line as appropriate :)

Thanks!

@@ -114,6 +119,7 @@ func resourceArmLoadBalancerCreate(d *schema.ResourceData, meta interface{}) err
name := d.Get("name").(string)
location := d.Get("location").(string)
resGroup := d.Get("resource_group_name").(string)
sku := convertSkuStringToLoadBalancerSku(d.Get("sku").(string))
Copy link
Contributor

Choose a reason for hiding this comment

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

rather than parsing this out I think we can make this network.LoadBalancerSkuName(d.Get("sku").(string))?

@@ -100,6 +100,11 @@ func resourceArmLoadBalancer() *schema.Resource {
},
},

"sku": {
Type: schema.TypeString,
Required: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

from what I can tell existing Load Balancers are of the Basic SKU; so we can instead default this to Basic and make this Optional; like so:

Default: string(network.LoadBalancerSkuNameBasic),
Optional: true,

^ this will mean that existing users don't need to specify the SKU (or update the configuration) for any existing Load Balancers. We can also extend this to add Validation and allow mixed-case strings (e.g. Basic and basic) via:

ValidateFunc: validation.StringInSlice([]string{
  string(network.LoadBalancerSkuNameBasic),
  string(network.LoadBalancerSkuNameStandard),
}, true),
DiffSupressFunc: ignoreCaseDiffSuppressFunc,

@justaugustus
Copy link
Contributor Author

@tombuildsstuff Thanks so much for the quick CR!

I've addressed your notes and have a few follow-up questions...

  1. The tests for basic and standard have the same resource names for azurerm_lb (test). Will that cause issues during testing?
  2. To support public LB Standard resources, we'll also need to make a similar addition of the sku parameter to the azurerm_public_ip resource. Should I include that change with this PR or send another one?

@justaugustus justaugustus changed the title [WIP] Add support for Azure LB Standard Add support for Azure LB Standard Jan 5, 2018
@tombuildsstuff
Copy link
Contributor

@justaugustus

I've addressed your notes and have a few follow-up questions...

  1. The tests for basic and standard have the same resource names for azurerm_lb (test). Will that cause issues during testing?

Each of the acceptance tests suffixes the resource names (in this case the LB Name) with a random integer/string to make the name unique across tests - so there shouldn't be any issues here.

  1. To support public LB Standard resources, we'll also need to make a similar addition of the sku parameter to the azurerm_public_ip resource. Should I include that change with this PR or send another one?

Ideally it should be split out into another PR (which we can merge before this one) - but given they're interdependent I don't see any harm combining them into one if that's easier :)

Thanks!

@justaugustus
Copy link
Contributor Author

I'll send another PR for the Public IP Standard SKU stuff.
Thanks again for the feedback, @tombuildsstuff!

@JunyiYi
Copy link

JunyiYi commented Jan 10, 2018

@justaugustus , thanks for your contribution.
@tombuildsstuff , CoreOS is trying to understand when this feature will be supported in Terraform. Maybe you can give the date after this pull request is merged.

Thanks.

@justaugustus
Copy link
Contributor Author

Hey @tombuildsstuff!
Changed my mind and decided to bundle the two SKUs in this PR (seemed simpler that way).

I added acceptance tests, but I was thinking through a few additional cases and a little unsure about how to approach them:

LB

Test SKU:

  • basic -> PASS
  • standard -> FAIL
  • OTHER -> FAIL

Test frontend IP config:

  • private -> PASS
  • public:
    • PIP SKU:
      • basic:
        • LB SKU:
          • basic -> PASS
          • standard -> FAIL
      • standard:
        • LB SKU:
          • basic -> FAIL
          • standard -> PASS

PIP

Test SKU:

  • basic -> PASS
  • standard:
    • allocation:
      • static -> PASS
      • dynamic -> FAIL
      • OTHER -> FAIL

Could you take another sweep through this?

@justaugustus justaugustus changed the title Add support for Azure LB Standard Add support for Azure LB Standard and Public IP Standard Jan 11, 2018
@tombuildsstuff tombuildsstuff modified the milestones: 1.0.1, 1.0.2 Jan 11, 2018
@justaugustus
Copy link
Contributor Author

@tombuildsstuff did you have a chance to take another look at this?

Copy link
Contributor

@paultyng paultyng left a comment

Choose a reason for hiding this comment

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

@justaugustus I found a couple cleanup things if you don't mind addressing those and then @tombuildsstuff can take another pass at this.

resource "azurerm_lb" "test" {
name = "arm-test-loadbalancer-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
Copy link
Contributor

Choose a reason for hiding this comment

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

got some mixed tabs and spaces 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.

@paultyng I'm noticing this across multiple files in the provider... are tabs or spaces preferred?

Optional: true,
Default: string(network.PublicIPAddressSkuNameBasic),
ForceNew: true,
ValidateFunc: validatePublicIpSku,
Copy link
Contributor

Choose a reason for hiding this comment

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

This could just be StringInSlice couldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

It depends what's being tested - but in general we're using the Constants/Enums in the SDK via the StringInSlice (at least for Strings) for newer resources; given these constants exist - could we switch this for a StringInSlice?

name = "acctestpublicip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
Copy link
Contributor

Choose a reason for hiding this comment

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

mixed tabs and spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paultyng I'm noticing this across multiple files in the provider... are tabs or spaces preferred?

* `public_ip_address_allocation` - (Required) Defines whether the IP address is stable or dynamic. Options are Static or Dynamic.
* `sku` - (Optional) The SKU of the Public IP. Accepted values are `Basic` and `Standard`. Defaults to `Basic`.

~> **Note** Public IP Standard SKUs require `public_ip_address_allocation` to be set to `static`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be in a validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paultyng Agreed that that should be in a validation as well!

I dropped a note (#665 (comment)) hoping for a nudge in the right direction re: the structuring the tests correctly and figured adding something in the docs was a good start while waiting for a response.

Copy link
Contributor

@tombuildsstuff tombuildsstuff Jan 22, 2018

Choose a reason for hiding this comment

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

@justaugustus apologies for the delayed response here.

At the current time it's only possible to access the value of that specific field in the validation method on the Schema - as such I believe we'd need to do this in the resourceArmPublicIpCreate method?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've added a commit to explain that this feature is still in Preview and needs to be opted-in

@justaugustus
Copy link
Contributor Author

@tombuildsstuff / @paultyng --
thanks for the feedback! I've addressed both of your reviews, so this is ripe for another sweep when you have a chance. :)

@tombuildsstuff
Copy link
Contributor

@justaugustus hey - just to let you know that now the SDK upgrade work is completed that I'm hoping to take a look into this later today (apologies for the delay here - we've been trying to minimise merge conflicts during the SDK migration) :)

tombuildsstuff
tombuildsstuff previously approved these changes Jan 26, 2018
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @justaugustus

Thanks for pushing those updates - apologies for the delayed re-review here.

I've taken a look through and have left a comment in-line which I'll push a commit to resolve - but this otherwise LGTM. I'll kick off the test suite now

Thanks!

}

if resp.PublicIPAddressPropertiesFormat.DNSSettings != nil && resp.PublicIPAddressPropertiesFormat.DNSSettings.Fqdn != nil && *resp.PublicIPAddressPropertiesFormat.DNSSettings.Fqdn != "" {
d.Set("fqdn", resp.PublicIPAddressPropertiesFormat.DNSSettings.Fqdn)
Copy link
Contributor

Choose a reason for hiding this comment

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

@tombuildsstuff tombuildsstuff dismissed paultyng’s stale review January 26, 2018 12:14

changes have been pushed since

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

Given this functionality is in Preview - I've added a couple of comments about documenting this (I'll push a commit to fix this shortly).

* `public_ip_address_allocation` - (Required) Defines whether the IP address is stable or dynamic. Options are Static or Dynamic.
* `sku` - (Optional) The SKU of the Public IP. Accepted values are `Basic` and `Standard`. Defaults to `Basic`.

~> **Note** Public IP Standard SKUs require `public_ip_address_allocation` to be set to `static`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I've added a commit to explain that this feature is still in Preview and needs to be opted-in

@@ -45,6 +45,7 @@ The following arguments are supported:
* `resource_group_name` - (Required) The name of the resource group in which to create the LoadBalancer.
* `location` - (Required) Specifies the supported Azure location where the resource exists.
* `frontend_ip_configuration` - (Optional) A frontend ip configuration block as documented below.
* `sku` - (Optional) The SKU of the Azure Load Balancer. Accepted values are `Basic` and `Standard`. Defaults to `Basic`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I've added a commit to explain that this feature is still in Preview and needs to be opted-in

@tombuildsstuff
Copy link
Contributor

Tests pass for both LB's and Public IP's after registering for the Preview:

screen shot 2018-01-26 at 16 02 13

screen shot 2018-01-26 at 16 02 17

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@tombuildsstuff tombuildsstuff merged commit b863434 into hashicorp:master Jan 26, 2018
tombuildsstuff added a commit that referenced this pull request Jan 26, 2018
@justaugustus
Copy link
Contributor Author

🎉

@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants