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

Resource and data source vcd_edgegateway add network support for multiple subnets, sub-allocated pools and rate limits #401

Merged
merged 32 commits into from
Dec 4, 2019

Conversation

Didainius
Copy link
Collaborator

@Didainius Didainius commented Nov 19, 2019

This PR closes #323, closes #397

This is a list of things it brings:

  • Deprecates existing external_networks list of networks in favor of new external_network block which allows to specify one or more subnets inside the network and suballocate IPs from those ranges. Also deprecates default_gateway_network field. Note: as far as I tested all external_network block features work with simple edge gateway as well
  • Adds additional external_network_ips computed field to get all IP addresses set on uplink gateway interfaces (in addition to default IP in default_external_network_ip field)
  • Adds additional test TestAccVcdEdgeGatewayParallelCreation which aims to catch a reported error when two edge gateways are being attached to the same external network at the same time (so far I did not reproduce the error)
  • Removed a limitation where field distributed_routing was not read due to older API version not returning it.
  • Adds new field fips_mode_enabled to enable FIPS mode (it must be enabled by vCD administrator in general settings to make it work, otherwise returns a human readable error). Note FIPS mode field is not being returned from API therefore it does not support read
  • Adds support for rate limiting per "external network"

Note: It does not yet support update.

Important. There is one problem with data sources which should be solved by this PR hashicorp/terraform-plugin-sdk#197 but is not yet done. The problem is that when a TypeSet contains only computed variables and there are multiple blocks, only one is stored. This situation is documented and tested in existing TestAccVcdEdgeGatewayExternalNetworks test

@Didainius Didainius self-assigned this Nov 19, 2019
@Didainius Didainius changed the title Resource and data source vcd_edgegateway add network support for multiple subnets and sub-allocated pools Resource and data source vcd_edgegateway add network support for multiple subnets, sub-allocated pools and rate limits Nov 20, 2019
@Didainius Didainius marked this pull request as ready for review November 20, 2019 13:44
@Didainius Didainius requested a review from vbauzys November 20, 2019 13:47
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

First comments. This one is big ;)

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Description: "If true, default gateway will be used for the edge gateways' default routing and DNS forwarding.(False by default)",
},
"external_network": {
Type: schema.TypeSet,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please confirm whether using TypeSet leads to the issue where changing (updating) value of any field in HCL shows the whole external_network block as being deleted and re-created during a terraform plan.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this will show it. Something like that:

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

A remotely related issue at HashiCorp for reference:
hashicorp/terraform#21901

"incoming_rate_limit": {
Computed: true,
Type: schema.TypeFloat,
Description: "Incoming rate limit (Mbps)",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please confirm that Mbps is what API is using (just want to make sure we avoid nasty conversion issues).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. And funny enough it works properly with float values (included in tests as well):
image

Copy link
Contributor

Choose a reason for hiding this comment

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

We have case where API and UI don't match Types.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, but these numbers in screenshot were created using provider, not entered manually.

vcd/datasource_vcd_edgegateway.go Show resolved Hide resolved
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

Documentation requests.

website/docs/r/edgegateway.html.markdown Outdated Show resolved Hide resolved
website/docs/r/edgegateway.html.markdown Outdated Show resolved Hide resolved
website/docs/r/edgegateway.html.markdown Outdated Show resolved Hide resolved
website/docs/r/edgegateway.html.markdown Outdated Show resolved Hide resolved
* `configuration` - (Required) Configuration of the vShield edge VM for this gateway. One of: `compact`, `full` ("Large"), `x-large`, `full4` ("Quad Large").
* `default_gateway_network` - (Optional) Name of the external network to be used as default gateway. It must be included in the
* `default_gateway_network` - (Deprecated, Optional) Name of the external network to be used as default gateway. It must be included in the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Which field replaces this deprecated one?
In general, it feels we should add a sentence to all deprecated fields saying "Please use ... instead" to avoid putting the user into detective clothes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added pointers - please check if it makes sense to have them at the end of description or I should move the new field descriptions to the front.

Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@vbauzys vbauzys left a comment

Choose a reason for hiding this comment

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

Overall complicated PR. Can't do good review do that code is complicated and have to know structures, changes, overall understand inside things. Also SDK upgrade should be as separate PR.

"incoming_rate_limit": {
Computed: true,
Type: schema.TypeFloat,
Description: "Incoming rate limit (Mbps)",
Copy link
Contributor

Choose a reason for hiding this comment

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

We have case where API and UI don't match Types.

// <OutRateLimit>100</OutRateLimit>
// <UseForDefaultRoute>true</UseForDefaultRoute>
// </GatewayInterface>
func getGatewayInterfacesType(vcdClient *VCDClient, externalInterfaceSet *schema.Set) ([]*types.GatewayInterface, error) {
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 divide this function with meaningful names to make self documented code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I split it, but IMHO the names are already meaningful as they can be with this API structure for interfaces. To me now it is even harder to follow it, but you can check if it is more readable for fresh eyes.

Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

One last doc polish in-line and LGTM. Thanks for a big addition!

default gateway. It must be included in the list of `external_networks`. Providing an empty string
or omitting the argument will create the edge gateway without a default gateway. **Please use**
the [external network](#external-network) block structure and `use_for_default_route` to specify
a subnet should be used as default route.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
a subnet should be used as default route.
a subnet which should be used as a default route.

@vbauzys
Copy link
Contributor

vbauzys commented Dec 3, 2019

Don't forget to solve conflicts

@Didainius Didainius merged commit 519ca43 into vmware:master Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants