cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

listNetworkOfferings api does not handle phyiscal network tags correctly

Open samapraku opened this issue 3 years ago • 6 comments

ISSUE TYPE
  • Bug Report
COMPONENT NAME
API, UI
CLOUDSTACK VERSION
4.17.0.1
CONFIGURATION

Advanced Network

OS / ENVIRONMENT

Ubuntu 20.04

SUMMARY

listNetworkOfferings api endpoint does not handle physical network tags correctly.

When creating a new Shared Guest network and a Physical network is selected, which has tags, the network offerings list in the dropdown is always empty

However, if the selected physical network does not have tags, the network offerings are populated

STEPS TO REPRODUCE

Create a Physical network with and without tags

In Networks -> Guest Network -> Add Network -> Shared

If the physical network has tags, the network offering dropdown is always empty.

Or make a listNetworkOfferings api request and pass a zoneid that has physical network that has no tags.

Issue likely caused by this line: https://github.com/apache/cloudstack/blob/bbc126057674a6cda047c2ea941d09af5c0e14a6/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java#L6600

if (isTagged != null) {
            if (isTagged) {
                sc.addAnd("tags", SearchCriteria.Op.NNULL);
            } else {
                sc.addAnd("tags", SearchCriteria.Op.NULL);
            }
        }
EXPECTED RESULTS
When a physical network has tags, listNetworkOfferings should take the tags into account
ACTUAL RESULTS

listNetworkOfferings always return empty when a physical network has tags


samapraku avatar Sep 18 '22 10:09 samapraku

Thanks for opening your first issue here! Be sure to follow the issue template!

boring-cyborg[bot] avatar Sep 18 '22 10:09 boring-cyborg[bot]

@samapraku Can you please confirm if for the given physical network, (Zone -> Specific Zone -> Physical Network (sub Tab) -> Specific Physical Network -> Network Service Providers (sub Tab) ) the necessary service providers enabled i.e, Virtual Router,etc? If not, can you enable the virtualrouterelement (via cmk, using configure virtualrouterelement cmd and you can get the id of the virtual router element, using list virtualrouterelements), once You've enabled the virtualrouterelement, enable the network service provider via UI.

Pearl1594 avatar Sep 19 '22 06:09 Pearl1594

@Pearl1594 These are already enabled under Network service providers

BaremetalPxeProvider, InternalLbVm, VirtualRouter, and VpcVirtualRouter

samapraku avatar Sep 19 '22 06:09 samapraku

Thanks for confirming. Do the network offerings have the same tags as set for the physical network?

Pearl1594 avatar Sep 19 '22 06:09 Pearl1594

Yes. Even when the same tags are set, the api still returns empty. If you look at the code snippet I added to the report, you will notice that that the if condition is redundant since both if and else blocks are doing the same thing

samapraku avatar Sep 19 '22 06:09 samapraku

I tried both from the UI and also with cmk and got same results

samapraku avatar Sep 19 '22 06:09 samapraku

@samapraku I tried to reproduce the issue with latest main branch but failed.

both api/ui work for me.

(localcloud) 🐱 > list networkofferings tags=test zoneid=7c9769a1-ba70-4f3a-a976-5a6ae7d946bb state=Enabled filter=id,name,tags
{
  "count": 1,
  "networkoffering": [
    {
      "id": "3db2b279-db80-40c5-a013-c1b236194641",
      "name": "test-tag",
      "tags": "test"
    }
  ]
}

can you share the results of your cmk commands ?

weizhouapache avatar Jan 05 '23 13:01 weizhouapache

if (isTagged) { sc.addAnd("tags", SearchCriteria.Op.NNULL); } else { sc.addAnd("tags", SearchCriteria.Op.NULL); } }

@samapraku this is fine. You may not notice the difference between NNULL and NULL

weizhouapache avatar Jan 05 '23 13:01 weizhouapache

Unable to reproduce the issue,

@samapraku Please check if the network offering contains the same tag as the physical networks,

Please let us know if we can close the issue

kiranchavala avatar Aug 07 '23 07:08 kiranchavala

@samapraku can you test with 4.18.0.0 ? I am closing this issue. If you still face same issue, please reopen the issue

(could be related to #6781)

weizhouapache avatar Aug 15 '23 14:08 weizhouapache