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 NAT rule handling IDs #216

Merged
merged 23 commits into from
Jul 19, 2019
Merged

Add NAT rule handling IDs #216

merged 23 commits into from
Jul 19, 2019

Conversation

vbauzys
Copy link
Contributor

@vbauzys vbauzys commented Jul 15, 2019

Ref: https://github.com/terraform-providers/terraform-provider-vcd/issues/244

Previous temporary functions were removed and new functions added to support ID handling. Majorly solves Nat rule removal.

vbauzys added 10 commits July 9, 2019 17:03
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>

# Conflicts:
#	CHANGELOG.md
#	govcd/edgegateway.go
#	govcd/edgegateway_test.go
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
@vbauzys vbauzys self-assigned this Jul 15, 2019
@vbauzys vbauzys changed the title Nat ext net support Add nat rule handling IDs Jul 15, 2019
@vbauzys vbauzys changed the title Add nat rule handling IDs Add NAT rule handling IDs Jul 15, 2019
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

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

Round 1 :)

Issue (others inline):
I've started tests: go test -tags functional -check.vv -check.f "Test_.*NAT.*" -timeout=15m . on an empty edge gateway.

START: api_vcd_test.go:250: TestVCD.SetUpSuite
PASS: api_vcd_test.go:250: TestVCD.SetUpSuite   15.232s

START: edgegateway_test.go:352: TestVCD.Test_AddDNATRule
PASS: edgegateway_test.go:352: TestVCD.Test_AddDNATRule 44.961s

START: edgegateway_test.go:282: TestVCD.Test_AddSNATRule
PASS: edgegateway_test.go:282: TestVCD.Test_AddSNATRule 44.865s

START: edgegateway_test.go:31: TestVCD.Test_NATMapping
PASS: edgegateway_test.go:31: TestVCD.Test_NATMapping   14.136s

START: edgegateway_test.go:77: TestVCD.Test_NATPortMapping
PASS: edgegateway_test.go:77: TestVCD.Test_NATPortMapping       14.119s

START: api_vcd_test.go:787: TestVCD.TearDownSuite
removeLeftoverEntries: [INFO] Attempting cleanup of vapp 'TestSetUpSuite' instantiated by createTestVapp
removeLeftoverEntries: [INFO] Removed vapp 'TestSetUpSuite' created by createTestVapp
PASS: api_vcd_test.go:787: TestVCD.TearDownSuite        0.288s

OK: 4 passed
PASS
ok      github.com/vmware/go-vcloud-director/v2/govcd   133.743s

After the tests I've got 2 nat rules left:
image

govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Show resolved Hide resolved
govcd/edgegateway.go Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
@vbauzys
Copy link
Contributor Author

vbauzys commented Jul 16, 2019

Test_NATPortMapping

Test_NATPortMapping and Test_NATMapping do this. These two methods use old delete which isn't working correctly in these test cases.

Possbile solutions:

  • leave as these are deprecated methods and deprecated tetss
  • change tests to use new delete method - may be possible. Test still will verify deprecated methods.

vbauzys added 3 commits July 16, 2019 11:30
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
@lvirbalas
Copy link
Collaborator

lvirbalas commented Jul 16, 2019

After the tests I've got 2 nat rules left:

@Didainius @vbauzysvmware was there resolution for this issue?

@vbauzys
Copy link
Contributor Author

vbauzys commented Jul 16, 2019

After the tests I've got 2 nat rules left:

@Didainius @vbauzysvmware was there resolution for this issue?

Test_NATPortMapping and Test_NATMapping do this - they are old unit tests. These two test methods use old delete which isn't working correctly in these test cases.

Possbile solutions:

leave as these are deprecated methods and deprecated tetss
change tests to use new delete method - may be possible. Test still will verify deprecated methods.

govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
@Didainius
Copy link
Collaborator

After the tests I've got 2 nat rules left:

@Didainius @vbauzysvmware was there resolution for this issue?

Test_NATPortMapping and Test_NATMapping do this - they are old unit tests. These two test methods use old delete which isn't working correctly in these test cases.

Possbile solutions:

leave as these are deprecated methods and deprecated tetss
change tests to use new delete method - may be possible. Test still will verify deprecated m

I vote for option 2 and fixing tests. It constantly leaves mess in NAT table and we will not remove it soon.

Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
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.

Some changes required. Will review again after tests

govcd/edgegateway.go Outdated Show resolved Hide resolved
// Allows to assign specific network Org VDC or external. Old function AddNATPortMapping and
// AddNATMapping assigns rule to first external network
func (eGW *EdgeGateway) AddDNATRule(ruleDetails NatRule) ([]*types.NatRule, error) {
// AddDNATRule creates DNAT rule and return created NAT struct or error.
Copy link
Contributor

Choose a reason for hiding this comment

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

"and return created NAT struct or error" -> "and returns the NAT struct that was created or an error"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
// AddNATMapping assigns rule to first external network
func (eGW *EdgeGateway) AddSNATRule(networkHref, externalIP, internalIP, description string) ([]*types.NatRule, error) {
// AddSNATRule creates SNAT rule and returns created NAT rule or error.
// Allows to assign specific Org VDC or external network.
Copy link
Contributor

Choose a reason for hiding this comment

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

"to assign" -> "assigning"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

govcd/edgegateway.go Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
vbauzys added 2 commits July 17, 2019 13:12
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
@vbauzys
Copy link
Contributor Author

vbauzys commented Jul 17, 2019

After the tests I've got 2 nat rules left:

@Didainius @vbauzysvmware was there resolution for this issue?

Test_NATPortMapping and Test_NATMapping do this - they are old unit tests. These two test methods use old delete which isn't working correctly in these test cases.
Possbile solutions:

leave as these are deprecated methods and deprecated tetss
change tests to use new delete method - may be possible. Test still will verify deprecated m

I vote for option 2 and fixing tests. It constantly leaves mess in NAT table and we will not remove it soon.

Changed to use new delete - now clean.

vbauzys added 2 commits July 17, 2019 14:25
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
vbauzys added 2 commits July 18, 2019 15:07
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
govcd/edgegateway.go Outdated Show resolved Hide resolved
govcd/edgegateway.go Outdated Show resolved Hide resolved
vbauzys added 2 commits July 19, 2019 10:44
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Signed-off-by: Vaidotas Bauzys <vbauzys@vmware.com>
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

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

Tests green on 9.5.

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
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.

LGTM!

@vbauzys vbauzys merged commit 3f6bb23 into vmware:master Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants