Skip to content

[Draft] server: do not allocate nic on public network for NSX VPC VR #10081

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

Draft
wants to merge 1 commit into
base: 4.20
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,6 @@ public interface VpcManager {
* @return
*/
boolean isSrcNatIpRequired(long vpcOfferingId);

boolean isSrcNatIpRequiredForVpcVr(long vpcOfferingId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3402,6 +3402,15 @@
&& vpcOffSvcProvidersMap.get(Service.Gateway).contains(Network.Provider.VPCVirtualRouter));
}

@Override
public boolean isSrcNatIpRequiredForVpcVr(long vpcOfferingId) {
final Map<Network.Service, Set<Network.Provider>> vpcOffSvcProvidersMap = getVpcOffSvcProvidersMap(vpcOfferingId);

Check warning on line 3407 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L3406-L3407

Added lines #L3406 - L3407 were not covered by tests
return (Objects.nonNull(vpcOffSvcProvidersMap.get(Network.Service.SourceNat))
&& vpcOffSvcProvidersMap.get(Network.Service.SourceNat).contains(Network.Provider.VPCVirtualRouter))
|| (Objects.nonNull(vpcOffSvcProvidersMap.get(Network.Service.Gateway))
&& vpcOffSvcProvidersMap.get(Service.Gateway).contains(Network.Provider.VPCVirtualRouter));
}

Check warning on line 3412 in server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java#L3412

Added line #L3412 was not covered by tests
Comment on lines +3405 to +3412
Copy link
Contributor

Choose a reason for hiding this comment

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

how about StaticNat (and maybe others)?

Copy link
Member Author

Choose a reason for hiding this comment

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

good question
To be honest, I never tested the case that SourceNat and StaticNat are provided by different providers (e.g. Nsx for Source NAT and VPCVirtualRouter for Static NAT). I do not think it will work.

this PR is aligned with the 4.19 code

@Override
public boolean isSrcNatIpRequired(long vpcOfferingId) {
final Map<Network.Service, Set<Network.Provider>> vpcOffSvcProvidersMap = getVpcOffSvcProvidersMap(vpcOfferingId);
return vpcOffSvcProvidersMap.get(Network.Service.SourceNat).contains(Network.Provider.VPCVirtualRouter);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, might work. As you create a method isSrcNatIpRequiredForVpcVr the contents seems appropriate, but its use is more like needsPublicInterface does it? and in that case we would also want to test if the VR needs to provide StaticNat. I think a Gateway could be on a static ip as well, in theory at least.

maybe rename the method?

Copy link
Member Author

Choose a reason for hiding this comment

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

for isolated networks (NATTED mode by default), it uses VR as SourceNat
for Routed networks, it uses VR as Gateway
in both cases, the VR needs a public IP (as Source NAT or Gateway)

For Static NAT, I think we do not need to add a public interface to the VR when VR is created.
when Static NAT is enabled, it may add a public interface if needed


/**
* rollingRestartVpc performs restart of routers of a VPC by first
* deploying a new VR and then destroying old VRs in rolling fashion. For
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected List<DeployDestination> findDestinations() {
@Override
protected boolean prepareDeployment() {
//Check if the VR is the src NAT provider...
isPublicNetwork = vpcMgr.isSrcNatIpRequired(vpc.getVpcOfferingId());
isPublicNetwork = vpcMgr.isSrcNatIpRequiredForVpcVr(vpc.getVpcOfferingId());

// Check if public network has to be set on VR
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void testGetNumberOfRoutersToDeploy() {

protected void driveTestPrepareDeployment(final boolean isRedundant, final boolean isPublicNw) {
// Prepare
when(vpcMgr.isSrcNatIpRequired(mockVpc.getVpcOfferingId())).thenReturn(isPublicNw);
when(vpcMgr.isSrcNatIpRequiredForVpcVr(mockVpc.getVpcOfferingId())).thenReturn(isPublicNw);

// Execute
final boolean canProceedDeployment = deployment.prepareDeployment();
Expand Down