Skip to content

Enhancement: Allow creating atmost 1 physical network with null tag#3780

Closed
ravening wants to merge 2 commits intoapache:mainfrom
ravening:feature_physical_ntwk_with_tags
Closed

Enhancement: Allow creating atmost 1 physical network with null tag#3780
ravening wants to merge 2 commits intoapache:mainfrom
ravening:feature_physical_ntwk_with_tags

Conversation

@ravening
Copy link
Copy Markdown
Member

Description

Currently, we can create multiple physical networks in the same traffic
types with null tags. This feature will ensure that we can create at most
1 physical network in the same traffic type with a null tag.

Every physical network should be associated with a tag so that when we create
a new shared network, using the tags we can match the shared network with
the physical network

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?

This feature has been tested through cloudmonkey commands

First we need to ensure that there is a spare NIC in the hypervisor on which we can create a new
physical network.

We are going to create a bridge with name "cloudbr9" on this new interface

1 . Create a physical network

create physicalnetwork zoneid=76aecb3c-c246-4cf7-9410-1116596a26f7 isolationmethods=VLAN name=TEST

2 . Create another physical network without any tag

create physicalnetwork zoneid=76aecb3c-c246-4cf7-9410-1116596a26f7 isolationmethods=VLAN name=TEST-2

3 . Now try to add traffic type to any of the physical network created above. This should fail since there are more than 1 physical network without any tags

add traffictype physicalnetworkid=fed2091b-9db9-40be-be32-4bdc2c4cdd23 traffictype=Guest kvmnetworklabel=cloudbr9


Error 530: There are more than 1 physical network without tags in the zone= 1

4 . Now add the tag to one of the physical network

update physicalnetwork id=fed2091b-9db9-40be-be32-4bdc2c4cdd23 tags=NGN

5 . Now we can successfully add the traffic type

 add traffictype physicalnetworkid=fed2091b-9db9-40be-be32-4bdc2c4cdd23 traffictype=Guest kvmnetworklabel=cloudbr9


cmd = org.apache.cloudstack.api.command.admin.usage.AddTrafficTypeCmd
jobid = 15afffb2-c600-428a-a691-a7767a145e84
jobinstanceid = 3995aec3-1cea-4f57-bce2-c99e34e54298
jobinstancetype = TrafficType
jobprocstatus = 0
jobresult:
traffictype:
id = 3995aec3-1cea-4f57-bce2-c99e34e54298
kvmnetworklabel = cloudbr9
physicalnetworkid = fed2091b-9db9-40be-be32-4bdc2c4cdd23
traffictype = Guest
jobresultcode = 0
jobresulttype = object
jobstatus = 1

6 . If we try to update the network to delete the tags, it should fail because there is already another network without tag

update physicalnetwork id=fed2091b-9db9-40be-be32-4bdc2c4cdd23 tags=Error

Async job 7d1e9b8a-95d1-4dd3-be3d-125e314a6bd5 failed
Error 530, There are more than 1 physical network without tags in the zone= 1

cmd = org.apache.cloudstack.api.command.admin.network.UpdatePhysicalNetworkCmd
jobid = 7d1e9b8a-95d1-4dd3-be3d-125e314a6bd5
jobprocstatus = 0
jobresult:
errorcode = 530
errortext = There are more than 1 physical network without tags in the zone= 1
jobresultcode = 530
jobresulttype = object
jobstatus = 2

Currently, we can create multiple physical networks in the same traffic
types with null tags. This feature will ensure that we can create atmost
1 physical network in the same traffic type with null tag.

Every physical network should be associted with a tag so that when we create
a new shared network, using the tags we can match the shared network with
the physical network
@andrijapanicsb
Copy link
Copy Markdown
Contributor

@radeksm I can see edge cases where this constraint can be useful (operator lack of understanding how things should be done/tagged), but otherwise, I don't see the usability of this in the wider sense - why at all putting such constraint? Apologies if I'm missing something....

@DaanHoogland
Copy link
Copy Markdown
Contributor

@rakgenius I can see how you want this. Can you answer @andrijapanicsb on to why enforce this and if you guys agree, can we hide this behind a global - or zone-wide setting?
@andrijapanicsb, I'll code-review if we have functional agreement.

@ravening
Copy link
Copy Markdown
Member Author

@andrijapanicsb @DaanHoogland Your point sounds valid. I can hide this behind a global setting or completely remove this feature if this is of no use to anyone. If I hide this feature behind the global setting, then I need to add lot of if conditions to see if this has to be enforced or not.

@ustcweizhou do you have any other solution?

@andrijapanicsb
Copy link
Copy Markdown
Contributor

in 4.13 at least (or was it master actually) you can't create Guest network if you have 2 physical networks both carrying Guest traffic and if tags are not in use (i.e. the network offering requires a tag). This solves the "guest network placements on a particular physical network" problem I believe?

I'm struggling to see the use case for these changes @rakgenius - what problem is this trying to solve?

@ravening
Copy link
Copy Markdown
Member Author

@andrijapanicsb in 4.7, we were able to create multiple physical networks without any tag in the same traffic type (storage/managment/guest). When we create a network offering with some tag, it should match to the physical network with the same tag. This is what we were trying to achieve.

If thats already solved in 4.13, then its good enough and I can close this PR

@andrijapanicsb
Copy link
Copy Markdown
Contributor

@rakgenius currently you can still create additional physical network, and then the Guest traffic in this physical network, without tags. But you have to define tags on the network offering and the physical network, so that should solve your issue if i understand correctly?

@ravening
Copy link
Copy Markdown
Member Author

@andrijapanicsb yes you can create additional physical network without tags but this PR ensures that there will be a max of 1 physical network without any tag in particular traffic type. As of today, I guess in a particular traffic type there can be multiple physical networks in same traffic type without tags.

@svenvogel
Copy link
Copy Markdown
Contributor

@rakgenius @andrijapanicsb i follow your discussion guys 🎅

if i understand it correctly the PR does the following.

before PR 🔕
N physical network without tag -> 1 network Offering with tag (tag has no influence) - 1:N relation only possible

after PR 🔔
N physical networks with tag -> N network offering with tag - 1:1 relation possible

is this correctly maybe i stand in the hose?

@ravening
Copy link
Copy Markdown
Member Author

ravening commented Dec 24, 2019

@rakgenius @andrijapanicsb i follow your discussion guys 🎅

if i understand it correctly the PR does the following.

before PR 🔕
N physical network without tag -> 1 network Offering with tag (tag has no influence) - 1:N relation only possible

after PR 🔔
N physical networks with tag -> N network offering with tag - 1:1 relation possible

is this correctly maybe i stand in the hose?

yes thats correct

@andrijapanicsb
Copy link
Copy Markdown
Contributor

I don't like imposing a limitation (unless its controlled via global setting and defaults to the old behaviour) - as it seems to me here we are trying to avoid an operator configuration error by imposing a hardcoded limit.

The correct scenario can be created by paying attention to the configuration of physical network, various traffic and network offering.

If one doesn't tag his offerings and physical networks, perhaps he has the reason to do so, or it is his job to understand what he is doing.

@svenvogel
Copy link
Copy Markdown
Contributor

@andrijapanicsb yes you can create additional physical network without tags but this PR ensures that there will be a max of 1 physical network without any tag in particular traffic type. As of today, I guess in a particular traffic type there can be multiple physical networks in same traffic type without tags.

@rakgenius i see there not a really problem. the PR only limits the creating of 1 additional physical network without tag. there are more interesting question. if there is a scenario where we want to create a second physical network without tag? what i see i can create an additional one but not add a traffic flag which is needed for the usage.

@weizhouapache
Copy link
Copy Markdown
Member

@svenvogel @andrijapanicsb @ravening
This PR aims the fix the issue in following scenario.

Suppose we have a physical network (without tag, name=PUB) and some network offerings (without tag, eg name=Network-offering)

Now, we want to add another physical network (PUB-NEW), and some network offerings (eg offering-NEW). To make it work, we have to tag all physical networks (PUB, PUB-NEW) and network offerings (Network-offering, Network-offering-NEW).

With this patch, we only need to tag the new physical network (PUB-NEW) and new network offerings (eg Network-offering-NEW). We do NOT need to tag/change the existing physical network (PUB) and network offering (eg Network-offering). The networks created from network offering without tag will be allocated to the physical network without tag (it means, at most 1 physical network is not tagged).

I hope it is clear.

@DaanHoogland
Copy link
Copy Markdown
Contributor

clear to me @weizhouapache, however a user would still want to be able to have all networks allowing all traffic in some installations, would you agree? So a global setting to enforce this would be nice.

@andrijapanicsb
Copy link
Copy Markdown
Contributor

Let me test this on 4.13, I don't recall seeing that requirement/limitation @weizhouapache...?

@andrijapanicsb
Copy link
Copy Markdown
Contributor

Thanks for the explanation @weizhouapache - this should be in the description of the PR in the first place :)

I've repeated commands that @ravening used to create 2 physical networks and attempt (and succeeded) to create a Guest traffic type on a specific Physical network (in clean 4.5 and clean 4.13)

On the other hand, with this clean (zero-tags-anywhere) setup (clean 4.5 or clean 4.13) - I can see the following "warning" in the API (same one in the GUI)

(localcloud) SBCM5> > create network networkofferingid=471039c4-d0f9-4105-a5d8-2e58551bf445 zoneid=450c5085-8832-46af-a60f-109a25af293a name=yyy displaytext==yyy
 Error: (HTTP 431, error code 4350) More than one physical networks exist in zone id=1 and no tags are specified in order to make a choice

So all checks are in place to ensure that an operator configures things "correctly".

Perhaps it's just me, but I don't see a value in the behaviour that this PR brings - it allows you to have at most 1 untagged physical network/offering combination - but why (what does it solve)? All one needs to do is to tag both the physical network and the offering and be 100% clear on what is going to be created where (update tags in DB).

As @DaanHoogland pointed out, the operator might have a valid case where he wants both (more than one) physical networks untagged.
So, can we please have a global configuration setting - that would make more sense (defaulting to the old behaviour)?

@weizhouapache
Copy link
Copy Markdown
Member

clear to me @weizhouapache, however a user would still want to be able to have all networks allowing all traffic in some installations, would you agree? So a global setting to enforce this would be nice.

@DaanHoogland in default installation (mostly used), there is only 1 physical network for guest networks (isolated/shared)

Thanks for the explanation @weizhouapache - this should be in the description of the PR in the first place :)

I've repeated commands that @ravening used to create 2 physical networks and attempt (and succeeded) to create a Guest traffic type on a specific Physical network (in clean 4.5 and clean 4.13)

On the other hand, with this clean (zero-tags-anywhere) setup (clean 4.5 or clean 4.13) - I can see the following "warning" in the API (same one in the GUI)

(localcloud) SBCM5> > create network networkofferingid=471039c4-d0f9-4105-a5d8-2e58551bf445 zoneid=450c5085-8832-46af-a60f-109a25af293a name=yyy displaytext==yyy
 Error: (HTTP 431, error code 4350) More than one physical networks exist in zone id=1 and no tags are specified in order to make a choice

So all checks are in place to ensure that an operator configures things "correctly".

Perhaps it's just me, but I don't see a value in the behaviour that this PR brings - it allows you to have at most 1 untagged physical network/offering combination - but why (what does it solve)? All one needs to do is to tag both the physical network and the offering and be 100% clear on what is going to be created where (update tags in DB).

As @DaanHoogland pointed out, the operator might have a valid case where he wants both (more than one) physical networks untagged.
So, can we please have a global configuration setting - that would make more sense (defaulting to the old behaviour)?

@DaanHoogland @andrijapanicsb
in current cloudstack implementation, if there are multiple (>=2) physical networks for guest networks (isolated/shared), all MUST be tagged (network offerings as well). Othewise cloudstack is not able to make decision which physical network will be used. That's same as the error message you got in your testing.

I think it makes sense. As a cloudstack user, when I create a guest network, I am very clear which physical network will be used. I do not think It is a good idea to let cloudstack choose a physical network from a list.

Maybe we are one of few cloudstack user who use multiple physical networks. On each hypervisor, there is a default interface for guest networks (which connect internet via core switches). meanwhile, there is another interface to connect to other dedicated racks in our data center which make us to build hybrid cloud very easily.

In default cloudstack setup , there is 1 physical network and some network offerings. all are not tagged. when we add new physical networks, we have to tag all physical networks and offerings, including the existing. as I said in previous comment, with this patch, we only need to tag the new things. It make our changes a bit easier.

@svenvogel
Copy link
Copy Markdown
Contributor

svenvogel commented Jan 9, 2020 via email

@svenvogel
Copy link
Copy Markdown
Contributor

@weizhouapache @andrijapanicsb @ravening @DaanHoogland some news here? how we can proceed here?

@weizhouapache
Copy link
Copy Markdown
Member

@svenvogel yes ,this change will not break anything. I agree it is better to have it.

ps: The tags of physical network and network offering can also be changed via api.

@DaanHoogland
Copy link
Copy Markdown
Contributor

@svenvogel I did not review because of the functional argument going on. I have no issue, myself.

@yadvr
Copy link
Copy Markdown
Member

yadvr commented Jan 29, 2020

@DaanHoogland @andrijapanicsb @weizhouapache @svenvogel - what's the consensus on this PR? Keep in 4.14 or move to 4.15?

@andrijapanicsb
Copy link
Copy Markdown
Contributor

After reading of Wei's explanation, it's became actually clear how it works, and I don't see it will break anything, but it would be good to document the behaviour in the docs.

LGTM

@DaanHoogland
Copy link
Copy Markdown
Contributor

ok @andrijapanicsb , so @rhtyd @weizhouapache @svenvogel we go ahead with it. I'll review asap, as only Wei has done so so far.
@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-712

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-854)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 28067 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr3780-t854-kvm-centos7.zip
Smoke tests completed. 78 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

Copy link
Copy Markdown
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

being pedantic (only about the java code). the code itself looks good.

Comment thread server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/network/NetworkModelImpl.java Outdated
Comment thread server/src/main/java/com/cloud/network/NetworkModelImpl.java Outdated
Comment thread server/src/main/java/com/cloud/network/NetworkServiceImpl.java
Comment thread server/src/main/java/com/cloud/network/NetworkServiceImpl.java Outdated
Comment thread server/src/main/java/com/cloud/network/NetworkServiceImpl.java Outdated
Comment thread server/src/main/java/com/cloud/network/NetworkServiceImpl.java
@ravening ravening requested a review from DaanHoogland April 28, 2020 15:17
@DaanHoogland
Copy link
Copy Markdown
Contributor

@ravening @weizhouapache please remind me once we have 4.14 out. looks good but haven't tested.

@shwstppr shwstppr added this to the 4.16.0.0 milestone Jan 25, 2021
@yadvr
Copy link
Copy Markdown
Member

yadvr commented Jun 17, 2021

ping @ravening

@weizhouapache weizhouapache self-requested a review June 17, 2021 08:19
@DaanHoogland
Copy link
Copy Markdown
Contributor

@ravening can you rebase, I'll revisit my review when done.

@nvazquez nvazquez modified the milestones: 4.16.0.0, unplanned Jun 28, 2021
@sureshanaparti
Copy link
Copy Markdown
Contributor

Hi @ravening , can you rebase the PR with latest main.

@nvazquez
Copy link
Copy Markdown
Contributor

nvazquez commented Feb 6, 2022

Hi @ravening can you please fix the conflicts? Is this PR ready for review?

@nvazquez nvazquez modified the milestones: 4.17.0.0, 4.18.0.0 Mar 5, 2022
@weizhouapache
Copy link
Copy Markdown
Member

@ravening
can you rebase this PR with latest main ?

Copy link
Copy Markdown
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

some comments on tests house-keeping

allocationstate="Enabled"
)
# Cleanup resources used
cleanup_resources(cls.apiclient, cls._cleanup)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
cleanup_resources(cls.apiclient, cls._cleanup)
super(TestMulipleNetworkCreation, cls).tearDownClass()

Comment on lines +68 to +85
try:
cls.physical_network = PhysicalNetwork.create(
cls.apiclient,
cls.services["l2-network"],
zoneid=cls.zone.id
)

cls.physical_network_2 = PhysicalNetwork.create(
cls.apiclient,
cls.services["l2-network"],
zoneid=cls.zone.id
)
except Exception as e:
cls.tearDownClass()
raise unittest.SkipTest(e)

cls._cleanup.append(cls.physical_network)
cls._cleanup.append(cls.physical_network_2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
try:
cls.physical_network = PhysicalNetwork.create(
cls.apiclient,
cls.services["l2-network"],
zoneid=cls.zone.id
)
cls.physical_network_2 = PhysicalNetwork.create(
cls.apiclient,
cls.services["l2-network"],
zoneid=cls.zone.id
)
except Exception as e:
cls.tearDownClass()
raise unittest.SkipTest(e)
cls._cleanup.append(cls.physical_network)
cls._cleanup.append(cls.physical_network_2)
try:
cls.physical_network = PhysicalNetwork.create(
cls.apiclient,
cls.services["l2-network"],
zoneid=cls.zone.id
)
cls._cleanup.append(cls.physical_network)
cls.physical_network_2 = PhysicalNetwork.create(
cls.apiclient,
cls.services["l2-network"],
zoneid=cls.zone.id
)
cls._cleanup.append(cls.physical_network_2)
except Exception as e:
cls.tearDownClass()
raise unittest.SkipTest(e)

Comment on lines +143 to +148
try:
# Clean up
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
try:
# Clean up
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
super(TestMulipleNetworkCreation, self).tearDown()

Comment on lines +224 to +229
self.physical_network_3 = PhysicalNetwork.create(
self.apiclient,
self.services["l2-network"],
isolationmethods="VLAN",
zoneid=self.zone.id
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.physical_network_3 = PhysicalNetwork.create(
self.apiclient,
self.services["l2-network"],
isolationmethods="VLAN",
zoneid=self.zone.id
)
self.physical_network_3 = PhysicalNetwork.create(
self.apiclient,
self.services["l2-network"],
isolationmethods="VLAN",
zoneid=self.zone.id
)
self.cleanup.append(self.physical_network_3)

Comment on lines +262 to +269
self.shared_network = Network.create(
self.apiclient,
self.services["network2"],
networkofferingid=self.network_offering.id,
zoneid=self.zone.id,
domainid=self.domain.id
#physicalnetworkid=self.physical_network_3.id
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.shared_network = Network.create(
self.apiclient,
self.services["network2"],
networkofferingid=self.network_offering.id,
zoneid=self.zone.id,
domainid=self.domain.id
#physicalnetworkid=self.physical_network_3.id
)
self.shared_network = Network.create(
self.apiclient,
self.services["network2"],
networkofferingid=self.network_offering.id,
zoneid=self.zone.id,
domainid=self.domain.id
#physicalnetworkid=self.physical_network_3.id
)
self.cleanup.append(self.shared_network)

Comment on lines +272 to +275
self.service_offering = ServiceOffering.create(
self.apiclient,
self.testdata["service_offerings"]["small"]
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.service_offering = ServiceOffering.create(
self.apiclient,
self.testdata["service_offerings"]["small"]
)
self.service_offering = ServiceOffering.create(
self.apiclient,
self.testdata["service_offerings"]["small"]
)
self.cleanup.append(self.service_offering)

Comment on lines +280 to +286
self.virtual_machine = VirtualMachine.create(
self.apiclient,
self.testdata["virtual_machine"],
templateid=self.template.id,
serviceofferingid=self.service_offering.id,
networkids=self.shared_network.id
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.virtual_machine = VirtualMachine.create(
self.apiclient,
self.testdata["virtual_machine"],
templateid=self.template.id,
serviceofferingid=self.service_offering.id,
networkids=self.shared_network.id
)
self.virtual_machine = VirtualMachine.create(
self.apiclient,
self.testdata["virtual_machine"],
templateid=self.template.id,
serviceofferingid=self.service_offering.id,
networkids=self.shared_network.id
)
self.cleanup.append(self.virtual_machine)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2022

Hi @${author}, your pull request has merge conflicts. Can you fix the conflicts and sync your branch with the base branch?

@weizhouapache
Copy link
Copy Markdown
Member

@ravening
can you please address the comments and fix the merge conflicts?

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.