Skip to content

Bug fix: De-associate IP address if enabling static nat fails#3836

Merged
yadvr merged 1 commit into
apache:masterfrom
ravening:bug_fix_snat_ip
Jan 31, 2020
Merged

Bug fix: De-associate IP address if enabling static nat fails#3836
yadvr merged 1 commit into
apache:masterfrom
ravening:bug_fix_snat_ip

Conversation

@ravening
Copy link
Copy Markdown
Member

Description

Associating static NAT on IP to VM fails even though the IP is not allocated.
When we try enable static NAT on second IP address to the same VM, the operation fails but the IP address is still allocated in the db and it can't be used to enable static NAT on different VM.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Screenshots (if appropriate):

How Has This Been Tested?

Steps to reproduce the issue

(1) create a vpc (vpc-001) and a vpc tier (vpc-001-001)

(2) create a vm (vm-001-001) in vpc-001-001

(3) acquire a public ip (ip-1) and enable static nat to vm-001-001,
operation succeeds.

(4) acquire a second public ip (ip-2) and enable static nat to the same vm vm-001-001.
The operation fails but the ip is still assigned to vpc tier vpc-001-001.
Note down the ip address and the id of it.

(5) create another vpc vpc-002, vpc tier vpc-001-002, and vm (vm-001-002) in the second tier

(6) enable static NAT on second IP ip-2 to vm-001-002.

Expected Result:

Enabling static NAT on second IP to vm vm-001-002 should be success

Actual result:
Operation fails as the IP is still allocated to first vpc/tier

@ravening ravening changed the title CLSTACK-784 - Deassociate IP address if enabling static nat fails Bug fix: De-associate IP address if enabling static nat fails Jan 24, 2020
@DaanHoogland
Copy link
Copy Markdown
Contributor

@ravening are you prepending an internal ticket id to this PR title? if so please remove and track the pr or github issue out of sight?

Steps to reproduce the issue

(1) create a vpc (vpc-001) and a vpc tier (vpc-001-001)

(2) create a vm (vm-001-001) in vpc-001-001

(3) acquire a public ip (ip-1) and enable static nat to vm-001-001,
operation succeeds.

(4) acquire a public ip (ip-2) and enable static nat to vm-001-001,
operation fails but the ip is still assigned to vpc tier vpc-001-001.
Note down the ip address and the id of it.

(5) create another vpc tier vpc-001-002, and vm (vm-001-002) in the tier

(6) enabled ip-2 static nat to vm-001-002, operation should succeed
@DaanHoogland
Copy link
Copy Markdown
Contributor

nothing said (maybe amend the commit too?)

Copy link
Copy Markdown
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

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

@ravening
Copy link
Copy Markdown
Member Author

nothing said (maybe amend the commit too?)

sorry. my bad. updated it now

Copy link
Copy Markdown
Member

@yadvr yadvr left a comment

Choose a reason for hiding this comment

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

LGTM, but needs both manual and smoke testings.

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✖centos6 ✔centos7 ✔debian. JID-672

@yadvr yadvr closed this Jan 29, 2020
@yadvr yadvr reopened this Jan 29, 2020
@yadvr
Copy link
Copy Markdown
Member

yadvr commented Jan 29, 2020

(test run failed at backend)
@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@apache apache deleted a comment from blueorangutan Jan 29, 2020
@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-837)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 41266 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr3836-t837-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_privategw_acl.py
Smoke tests completed. 77 look OK, 1 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
test_02_vpc_privategw_static_routes Failure 269.07 test_privategw_acl.py
test_03_vpc_privategw_restart_vpc_cleanup Failure 253.12 test_privategw_acl.py

@ravening
Copy link
Copy Markdown
Member Author

@rhtyd @DaanHoogland the smoke test cases are failing because pvt gateway connectivity issue.

AssertionError: Ping to VM on Network Tier N from VM in Network Tier A should be successful at least for 2 out of 3 VMs

I guess this shouldn't be affected from my change as it involves deassociating ip from vm if the api fails and nothing else. Any opinions?

@yadvr
Copy link
Copy Markdown
Member

yadvr commented Jan 31, 2020

@weizhouapache can you comment? Thanks.

@weizhouapache
Copy link
Copy Markdown
Member

weizhouapache commented Jan 31, 2020

@weizhouapache can you comment? Thanks.

@rhtyd
I have manually tested it.

Same logic here:

https://github.com/apache/cloudstack/blob/master/server/src/main/java/com/cloud/network/rules/RulesManagerImpl.java#L233

@yadvr yadvr merged commit 6d014fa into apache:master Jan 31, 2020
ustcweizhou pushed a commit to ustcweizhou/cloudstack that referenced this pull request Feb 28, 2020
…#3836)

Associating static NAT on IP to VM fails even though the IP is not allocated.
When we try enable static NAT on second IP address to the same VM, the operation fails but the IP address is still allocated in the db and it can't be used to enable static NAT on different VM.

Steps to reproduce the issue:

(1) create a vpc (vpc-001) and a vpc tier (vpc-001-001)

(2) create a vm (vm-001-001) in vpc-001-001

(3) acquire a public ip (ip-1) and enable static nat to vm-001-001,
operation succeeds.

(4) acquire a public ip (ip-2) and enable static nat to vm-001-001,
operation fails but the ip is still assigned to vpc tier vpc-001-001.
Note down the ip address and the id of it.

(5) create another vpc tier vpc-001-002, and vm (vm-001-002) in the tier

(6) enabled ip-2 static nat to vm-001-002, operation should succeed
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.

6 participants