Skip to content

server: refactor listNetworks api database retrievals - #9184

Merged
sureshanaparti merged 6 commits into
apache:4.19from
shapeblue:refactor-listnetworks-execution
Jun 28, 2024
Merged

server: refactor listNetworks api database retrievals#9184
sureshanaparti merged 6 commits into
apache:4.19from
shapeblue:refactor-listnetworks-execution

Conversation

@shwstppr

Copy link
Copy Markdown
Contributor

Description

This PR attempts to optimize database queries during listNetworks API call. It should fix pagination-related issues as well while querying desired networks from the database. Only in the following cases, it may query all networks:

  • API param canusefordeploy is passed as true
  • Any service specified with the supportedservices API parameter

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)
  • build/CI

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@codecov

codecovBot commented Jun 6, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 70 lines in your changes missing coverage. Please review.

Project coverage is 14.98%. Comparing base (631d6ad) to head (3a97fae).
Report is 102 commits behind head on 4.19.

FilesPatch %Lines
...ain/java/com/cloud/network/NetworkServiceImpl.java0.00%70 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## 4.19 #9184 +/- ##
============================================
+ Coverage 14.96% 14.98% +0.02% - Complexity 10991 11048 +57 
============================================
Files 5373 5389 +16 Lines 469203 470603 +1400 Branches 60225 58405 -1820 ============================================
+ Hits 70198 70517 +319 - Misses 391232 392251 +1019 - Partials 7773 7835 +62 
FlagCoverage Δ
uitests4.28% <ø> (-0.03%)⬇️
unittests15.69% <0.00%> (+0.02%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@weizhouapache

Copy link
Copy Markdown
Member

good idea

@DaanHooglandDaanHoogland added this to the 4.19.1.0 milestone Jun 6, 2024
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9810

@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-10382)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 48773 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9184-t10382-kvm-centos7.zip
Smoke tests completed. 131 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9836

@shwstppr

Copy link
Copy Markdown
ContributorAuthor

In my testing, listing networks is working fine with the changes and smoke tests didn't report any error. Marking it ready for review

@shwstpprshwstppr changed the title [WIP] server: refactor listNetworks api database retrievalsserver: refactor listNetworks api database retrievalsJun 10, 2024
@shwstppr
shwstppr marked this pull request as ready for review June 10, 2024 09:41

@yadvryadvr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, didn't test it but needs testing on:

  • networks by roles: admin, domain admin, normal user
  • list networks by projects, accounts, domains
  • list networks in env with variety of networks across roles; isolated networks, VPC tier/network, shared network, L2 network and user-shared network

@sureshanapartisureshanaparti left a comment

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.

clgtm

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

networksToReturn.addAll(listAccountSpecificNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType, physicalNetworkId, networkOfferingId,
aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags, display, vlanId, associatedNetworkId), searchFilter, permittedAccounts));
additionalSearchCriteria.addOr("id", SearchCriteria.Op.SC,
getAccountSpecificNetworksSearchCriteria(sb, permittedAccounts, skipProjectNetworks));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If getAccountSpecificNetworksSearchCriteria returns null, the request fails with a bad sql query.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks @vishesh92 will check

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@vishesh92 it was due to empty searchcriteria at line 2392. Should be fixed now.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el7 ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 10141

@shwstppr

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10145

@yadvr

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@borisstoyanovborisstoyanov left a comment

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.

LGTM, checked manually for admin/user visibility of shared networks and for networks deployed within projects

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-10639)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 37134 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9184-t10639-kvm-centos7.zip
Smoke tests completed. 97 look OK, 34 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
ContextSuite context=TestTemplateHierarchy>:setupError8.27test_accounts.py
test_01_events_resourceFailure0.02test_events_resource.py
ContextSuite context=TestDeployVmWithAffinityGroup>:setupError0.00test_affinity_groups.py
ContextSuite context=TestMultipleVolumeAttach>:setupError0.00test_attach_multiple_volumes.py
ContextSuite context=TestDummyBackupAndRecovery>:setupError0.00test_backup_recovery_dummy.py
ContextSuite context=TestVeeamBackupAndRecovery>:setupError0.00test_backup_recovery_veeam.py
test_01_condensed_drs_algorithmError0.00test_cluster_drs.py
test_02_balanced_drs_algorithmError0.00test_cluster_drs.py
ContextSuite context=TestConsoleEndpoint>:setupError0.00test_console_endpoint.py
test_01_deploy_vm_with_extraconfig_throws_exception_kvmError0.10test_deploy_vm_extra_config_data.py
test_02_deploy_vm_with_extraconfig_kvmError0.07test_deploy_vm_extra_config_data.py
test_03_update_vm_with_extraconfig_kvmError0.06test_deploy_vm_extra_config_data.py
ContextSuite context=TestDeployVmRootSize>:setupError0.00test_deploy_vm_root_resize.py
ContextSuite context=TestHostControlState>:setupError27.24test_host_control_state.py
ContextSuite context=TestImportAndUnmanageVolumes>:setupError0.00test_import_unmanage_volumes.py
test_11_test_unmanaged_cluster_lifecycleError2.30test_kubernetes_clusters.py
ContextSuite context=TestListVolumes>:setupError0.00test_list_volumes.py
ContextSuite context=TestNetworkMigration>:setupError0.00test_migration.py
test_03_network_operations_on_created_vm_of_otheruserError1.20test_network_permissions.py
test_04_deploy_vm_for_other_user_and_test_vm_operationsFailure0.05test_network_permissions.py
ContextSuite context=TestSharedNetwork>:setupError56.59test_network.py
test_01_nicError0.05test_nic.py
test_01_non_strict_host_anti_affinityError2.17test_nonstrict_affinity_group.py
test_02_non_strict_host_affinityError1.13test_nonstrict_affinity_group.py
ContextSuite context=TestL2PersistentNetworks>:setupError0.00test_persistent_network.py
test_01_add_primary_storage_disabled_hostFailure0.06test_primary_storage.py
test_01_primary_storage_iscsiFailure0.06test_primary_storage.py
test_01_primary_storage_nfsFailure0.06test_primary_storage.py
ContextSuite context=TestStorageTags>:setupError0.15test_primary_storage.py
ContextSuite context=TestPrivateGwACLOvsGRE>:setupError0.00test_privategw_acl_ovs_gre.py
ContextSuite context=TestTemplates>:setupError36.51test_templates.py
test_01_positive_tests_usageFailure2.93test_usage_events.py
ContextSuite context=TestLBRuleUsage>:setupError2.24test_usage.py
ContextSuite context=TestNatRuleUsage>:setupError2.28test_usage.py
ContextSuite context=TestPublicIPUsage>:setupError2.32test_usage.py
ContextSuite context=TestSnapshotUsage>:setupError2.38test_usage.py
ContextSuite context=TestTemplateUsage>:setupError2.43test_usage.py
ContextSuite context=TestVmUsage>:setupError2.48test_usage.py
ContextSuite context=TestVolumeUsage>:setupError2.57test_usage.py
ContextSuite context=TestVpnUsage>:setupError2.62test_usage.py
ContextSuite context=TestVmAutoScaling>:setupError0.00test_vm_autoscaling.py
test_01_deploy_vm_on_specific_hostError0.05test_vm_deployment_planner.py
test_02_deploy_vm_on_specific_clusterError0.04test_vm_deployment_planner.py
test_03_deploy_vm_on_specific_podError0.07test_vm_deployment_planner.py
test_04_deploy_vm_on_host_override_pod_and_clusterError0.08test_vm_deployment_planner.py
test_05_deploy_vm_on_cluster_override_podError0.05test_vm_deployment_planner.py
ContextSuite context=TestDeployVM>:setupError0.00test_vm_life_cycle.py
ContextSuite context=TestKVMLiveMigration>:setupError0.00test_vm_life_cycle.py
ContextSuite context=TestMigrateVMwithVolume>:setupError0.00test_vm_life_cycle.py
ContextSuite context=TestSecuredVmMigration>:setupError0.00test_vm_life_cycle.py
ContextSuite context=TestVMLifeCycle>:setupError0.06test_vm_life_cycle.py
ContextSuite context=TestUnmanageVM>:setupError0.00test_vm_lifecycle_unmanage_import.py
ContextSuite context=TestVMSchedule>:setupError0.00test_vm_schedule.py
ContextSuite context=TestVmSnapshot>:setupError0.07test_vm_snapshots.py
ContextSuite context=TestVnfTemplates>:setupError0.00test_vnf_templates.py
ContextSuite context=TestCreateVolume>:setupError0.00test_volumes.py
ContextSuite context=TestVolumeEncryption>:setupError0.00test_volumes.py
ContextSuite context=TestVolumes>:setupError0.00test_volumes.py
test_02_cancel_host_maintenace_with_migration_jobsFailure0.14test_host_maintenance.py
test_03_cancel_host_maintenace_with_migration_jobs_failureError0.19test_host_maintenance.py
ContextSuite context=TestHostMaintenanceAgents>:setupError0.26test_host_maintenance.py

@apacheapache deleted a comment from blueorangutanJun 27, 2024
@apacheapache deleted a comment from blueorangutanJun 27, 2024
@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10190

@sureshanaparti

Copy link
Copy Markdown
Contributor

Merging based on manual tests & reviews.

@sureshanaparti
sureshanaparti merged commit c7f1ba5 into apache:4.19Jun 28, 2024
@DaanHoogland
DaanHoogland deleted the refactor-listnetworks-execution branch July 1, 2024 06:52
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Jul 2, 2024
* server: refactor listNetworks api database retrievals
* fixes
* remove unused methods
* imports
* fix empty searchcriteria issue
* refactor
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
nvazquez added a commit that referenced this pull request Aug 6, 2024
* server, api, ui: access improvements and assorted fixes
Fixes domain-admin access check to prevent unauthorized access.
Co-authored-by: Fabricio Duarte <fabricio.duarte.jr@gmail.com>
Co-authored-by: nvazquez <nicovazquez90@gmail.com>
Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
* Revert "server: refactor listNetworks api database retrievals (#9184)"
This reverts commit c7f1ba5.
* Fix snapshot chain being deleted on XenServer (#9447)
Using XenServer as the hypervisor, when deleting a snapshot that has a parent, that parent will also get erased on storage, causing data loss. This behavior was introduced with #7873, where the list of snapshot states that can be deleted was changed to add BackedUp snapshots.
This PR changes the states list back to the original list, and swaps the while loop for a do while loop to account for the changes in #7873.
Fixes#9446
* UI: Display Firewall, LB and Port Forwading rules tab for CKS clusters deployed on isolated networks (#9458)
---------
Co-authored-by: nvazquez <nicovazquez90@gmail.com>
Co-authored-by: Fabricio Duarte <fabricio.duarte.jr@gmail.com>
Co-authored-by: João Jandre <48719461+JoaoJandre@users.noreply.github.com>
Co-authored-by: Pearl Dsilva <pearl1594@gmail.com>
nvazquez added a commit that referenced this pull request Aug 6, 2024
* server, api, ui: access improvements and assorted fixes
Fixes domain-admin access check to prevent unauthorized access.
Co-authored-by: Fabricio Duarte <fabricio.duarte.jr@gmail.com>
Co-authored-by: nvazquez <nicovazquez90@gmail.com>
Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
* Revert "server: refactor listNetworks api database retrievals (#9184)"
This reverts commit c7f1ba5.
* Fix snapshot chain being deleted on XenServer (#9447)
Using XenServer as the hypervisor, when deleting a snapshot that has a parent, that parent will also get erased on storage, causing data loss. This behavior was introduced with #7873, where the list of snapshot states that can be deleted was changed to add BackedUp snapshots.
This PR changes the states list back to the original list, and swaps the while loop for a do while loop to account for the changes in #7873.
Fixes#9446
* UI: Display Firewall, LB and Port Forwading rules tab for CKS clusters deployed on isolated networks (#9458)
---------
Co-authored-by: nvazquez <nicovazquez90@gmail.com>
Co-authored-by: Fabricio Duarte <fabricio.duarte.jr@gmail.com>
Co-authored-by: João Jandre <48719461+JoaoJandre@users.noreply.github.com>
Co-authored-by: Pearl Dsilva <pearl1594@gmail.com>
winterhazel pushed a commit to scclouds/cloudstack that referenced this pull request Aug 11, 2024
* server: refactor listNetworks api database retrievals
* fixes
* remove unused methods
* imports
* fix empty searchcriteria issue
* refactor
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Aug 22, 2024
* server, api, ui: access improvements and assorted fixes
Fixes domain-admin access check to prevent unauthorized access.
Co-authored-by: Fabricio Duarte <fabricio.duarte.jr@gmail.com>
Co-authored-by: nvazquez <nicovazquez90@gmail.com>
Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
* Revert "server: refactor listNetworks api database retrievals (apache#9184)"
This reverts commit c7f1ba5.
* Fix snapshot chain being deleted on XenServer (apache#9447)
Using XenServer as the hypervisor, when deleting a snapshot that has a parent, that parent will also get erased on storage, causing data loss. This behavior was introduced with apache#7873, where the list of snapshot states that can be deleted was changed to add BackedUp snapshots.
This PR changes the states list back to the original list, and swaps the while loop for a do while loop to account for the changes in apache#7873.
Fixesapache#9446
* UI: Display Firewall, LB and Port Forwading rules tab for CKS clusters deployed on isolated networks (apache#9458)
---------
Co-authored-by: nvazquez <nicovazquez90@gmail.com>
Co-authored-by: Fabricio Duarte <fabricio.duarte.jr@gmail.com>
Co-authored-by: João Jandre <48719461+JoaoJandre@users.noreply.github.com>
Co-authored-by: Pearl Dsilva <pearl1594@gmail.com>
shwstppr added a commit to shapeblue/cloudstack that referenced this pull request Sep 5, 2024
* server: refactor listNetworks api database retrievals
* fixes
* remove unused methods
* imports
* fix empty searchcriteria issue
* refactor
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Abhishek's Bugfix List
Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants

@shwstppr@weizhouapache@blueorangutan@sureshanaparti@yadvr@vishesh92@borisstoyanov@DaanHoogland