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 tags support for Neutron Networks #454

Merged
merged 1 commit into from
Oct 30, 2018

Conversation

hardys
Copy link
Contributor

@hardys hardys commented Oct 22, 2018

This adds support for tags to networks, note this is branched from PR #446 since that already adds initial support for tags for the trunk resource, and a couple of functions are reused here.

Subsequent PRs will add support for the other neutron resources which support standard attribute tags as described in Issue #453

Issue #453

@hardys hardys changed the title Add tags support for Neutron Networks WIP: Add tags support for Neutron Networks Oct 22, 2018
@hardys
Copy link
Contributor Author

hardys commented Oct 22, 2018

Marking this WIP because the trunk patch from @celebdor has some build failures breaking the tests - when that's resolved I'll rebase this but it's otherwise ready for review.

If the approach taken here is OK I'll go ahead and push PRs/patches for the remaining resources using a similar pattern @jtopjian would you prefer one PR per resource or adding commits to this PR for all resources? I assume the former similar to gophercloud but wanted to check.

@ghost ghost added the size/XXL label Oct 22, 2018
@theopenlab-ci
Copy link

theopenlab-ci bot commented Oct 22, 2018

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Oct 23, 2018

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

return
}

func testAccCheckNetworkingV2Tags(name string, key string, tags []string) resource.TestCheckFunc {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Small nit - now this function has been renamed we could probably drop the key parameter, as it'll always be "tags" I think?

@theopenlab-ci
Copy link

theopenlab-ci bot commented Oct 23, 2018

Build failed.

@hardys hardys force-pushed the neutron_tags branch 2 times, most recently from 7a933dd to e2e747e Compare October 23, 2018 13:47
@theopenlab-ci
Copy link

theopenlab-ci bot commented Oct 23, 2018

Build failed.

@hardys hardys changed the title WIP: Add tags support for Neutron Networks Add tags support for Neutron Networks Oct 24, 2018
@theopenlab-ci
Copy link

theopenlab-ci bot commented Oct 24, 2018

Build succeeded.

@hardys
Copy link
Contributor Author

hardys commented Oct 24, 2018

@jtopjian when you have time this is ready for review I think - I've rebased on the latest trunk patch and the tests are all now green.

I've also started staging the remaining patches at https://github.com/hardys/terraform-provider-openstack/tree/neutron_tags_wip but I'll defer pushing PRs until we've iterated on this patch as I assume any review feedback will be common to all in the series and I don't want to waste CI cycles.

Thanks!

@hardys
Copy link
Contributor Author

hardys commented Oct 24, 2018

Note I've added the test for network to the per-resource test, but that will end up a little inefficient as we end up creating a network for other tests e.g subnet/port etc as well.

This is kind of a side-effect of the one PR per resource requirement I think, but I could probably refactor the test at the end of the series to a single template which creates all-the-resources that support tags?

@hardys
Copy link
Contributor Author

hardys commented Oct 24, 2018

Rebased on master now the trunk patch landed, also fixed a minor issue in the docs markdown.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Oct 24, 2018

Build succeeded.

@jtopjian
Copy link
Contributor

@hardys I'm going to be away for the next few days and might not get a chance to review this in detail. I'll do it as soon as I can, though.

This is kind of a side-effect of the one PR per resource requirement I think, but I could probably refactor the test at the end of the series to a single template which creates all-the-resources that support tags?

Good idea :)

@hardys
Copy link
Contributor Author

hardys commented Oct 25, 2018

Good idea :)

Ok I'll look into it as the current tests are a bit slow:

[shardy@localhost terraform-provider-openstack]$ TF_ACC=1 go test -v -run "TestAccNetworkingV2.*_tags" github.com/terraform-providers/terraform-provider-openstack/openstack -count=1
=== RUN   TestAccNetworkingV2FloatingIP_tags
--- PASS: TestAccNetworkingV2FloatingIP_tags (34.73s)
=== RUN   TestAccNetworkingV2Network_tags
--- PASS: TestAccNetworkingV2Network_tags (28.52s)
=== RUN   TestAccNetworkingV2Port_tags
--- PASS: TestAccNetworkingV2Port_tags (65.28s)
=== RUN   TestAccNetworkingV2Router_tags
--- PASS: TestAccNetworkingV2Router_tags (30.82s)
=== RUN   TestAccNetworkingV2SecGroup_tags
--- PASS: TestAccNetworkingV2SecGroup_tags (21.24s)
=== RUN   TestAccNetworkingV2Subnet_tags
--- PASS: TestAccNetworkingV2Subnet_tags (44.90s)
=== RUN   TestAccNetworkingV2SubnetPool_tags
--- PASS: TestAccNetworkingV2SubnetPool_tags (24.06s)
=== RUN   TestAccNetworkingV2Trunk_tags
--- PASS: TestAccNetworkingV2Trunk_tags (63.71s)
PASS
ok  	github.com/terraform-providers/terraform-provider-openstack/openstack	313.268s

I guess this duplication isn't unique to the tags test, but if I refactor things to have a new e.g TestAccNetworkingV2_tags common test we can at least remove the Network/Subnet test overhead (since those are already created for the Port test) which is over 1min and I suspect using a single terraform invocation/template will reduce the overall test overhead quite a bit as well.

@hardys
Copy link
Contributor Author

hardys commented Oct 25, 2018

Ok I refactored the tests for the entire series and it's a lot faster:

[shardy@localhost openstack]$ TF_ACC=1 go test -v -run "TestAccNetworkingV2_tags" github.com/terraform-providers/terraform-provider-openstack/openstack -count=1
=== RUN   TestAccNetworkingV2_tags
--- PASS: TestAccNetworkingV2_tags (94.14s)
PASS
ok  	github.com/terraform-providers/terraform-provider-openstack/openstack	94.154s

@hardys
Copy link
Contributor Author

hardys commented Oct 25, 2018

Ok the latest revision has a separate test for tags, and the series at https://github.com/hardys/terraform-provider-openstack/commits/neutron_tags_wip adds to the test which speeds things up considerably.

When this passes CI I'll push a couple more of the pending patches as dependent PRs as I think that neutron_tags_wip branch is all ready for review now.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Oct 25, 2018

Build failed.

@hardys
Copy link
Contributor Author

hardys commented Oct 29, 2018

recheck

@theopenlab-ci
Copy link

theopenlab-ci bot commented Oct 29, 2018

Build succeeded.

@@ -112,6 +114,7 @@ The following attributes are exported:
* `tenant_id` - See Argument Reference above.
* `admin_state_up` - See Argument Reference above.
* `availability_zone_hints` - See Argument Reference above.
* `tags` - Argument Reference above.
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep it similar to other attributes: "See Argument Reference above.".

Copy link
Member

@ozerovandrei ozerovandrei left a comment

Choose a reason for hiding this comment

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

Looks good, i think it only needs a small fix in website documentation.

This allows us to set/get tags for networks via terraform templates,
and requires the recently added changes to gophercloud that enable
the relevant features of the Neutron APIs to be accessed.

Note the test is added in a new resource_openstack_networking_tags_v2_test.go
file, so that we can reduce duplication later in the series e.g
subnet/port/trunk resources can share the same template which should be faster.

Issue: terraform-provider-openstack#453
@hardys
Copy link
Contributor Author

hardys commented Oct 29, 2018

@ozerovandrei thanks for the review - I fixed the docs nit in the latest revision.

@theopenlab-ci
Copy link

theopenlab-ci bot commented Oct 29, 2018

Build succeeded.

Copy link
Member

@ozerovandrei ozerovandrei left a comment

Choose a reason for hiding this comment

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

LGTM!

@jtopjian jtopjian merged commit 24a01ab into terraform-provider-openstack:master Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants