Skip to content

Restore listNetworks behavior & clean up the code - #9461

Merged
DaanHoogland merged 2 commits into
apache:4.19from
scclouds:fix-listnetworks-query
Sep 9, 2024
Merged

Restore listNetworks behavior & clean up the code#9461
DaanHoogland merged 2 commits into
apache:4.19from
scclouds:fix-listnetworks-query

Conversation

@winterhazel

@winterhazelwinterhazel commented Jul 29, 2024

Copy link
Copy Markdown
Member

Description

PR #9184 attempted to optimize the listNetworks API by converting the multiple queries that were performed into a single one. This was done by building multiple search criterias for the individual queries, OR-adding them to an intermediary search criteria, and AND-adding the intermediary to a final one. However, this did not work as intended, because the code does not carry the joins' conditions when adding a search criteria into another one.

This PR fixes the issue, making the final query work as intended by #9184. This was done by explicitly adding the join parameters to each query's WHERE clause, which will then be included in the intermediary search criteria and in the final query. I also cleaned up the related code.

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)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

How Has This Been Tested?

My environment had the following domains, accounts, projects and networks (networks beginning with an "i" are isolated, and with a "s" are shared):

  • ROOT: admin (root admin; networks iadmin, created sadmin), ur (user; network iur), pr (project; network ipr; has accounts admin, ur)
  • ROOT/d1: d1 (domain admin; networks id1, created sd1), ud1 (user; network iud1), pd1 (project; network ipd1; has account d1)
  • ROOT/d2: d2 (domain admin; network id2, created sd2)

Through the UI, in every account, I listed the networks using the all/account/domain/shared filters with the project toggle on/off. I compared the behavior for the same environment in a commit before #9184, and verified that it was the same. Below is a table showing which networks were listed for each account and filter combination.

Account/filterAll, project offAccount, project offDomain, project offShared, project offAll, project onAccount, project onDomain, project onShared, project on
adminid2,iud1,id1,iur,iadmin,sd2,sd1,sadminid2,iud1,id1,iur,iadminSee [1]Empty, see [2]ipd1,ipr,sd2,sd1,sadminipd1,iprSee [1]Empty, see [2]
uriur,sadminiurSee [1]Empty, see [2]ipr,sadminiprSee [1]Empty, see [2]
d1iud1,id1,sd1,sadminiud1,id1See [1]Empty, see [2]ipd1,sd1,sadminipd1See [1]Empty, see [2]
ud1iud1,sd1,sadminiud1See [1]Empty, see [2]sd1,sadminEmptySee [1]Empty, see [2]
d2id2,sd2,sadminid2See [1]Empty, see [2]sd2,sadminEmptySee [1]Empty, see [2]

[1] When filtering by domain, I got Invalid value of networkfilter: domainpath. This was already present before #9184.
[2] This is probably not the intended behavior, and was already present before #9184. It can be fixed in a separate PR, as this one only aims to restore the original filtering behavior.

@winterhazel

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@winterhazel 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.

@codecov

codecovBot commented Jul 29, 2024

Copy link
Copy Markdown

Codecov Report

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

Project coverage is 15.08%. Comparing base (bf11676) to head (8cf2987).
Report is 33 commits behind head on 4.19.

Files with missing linesPatch %Lines
...ain/java/com/cloud/network/NetworkServiceImpl.java0.00%94 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## 4.19 #9461 +/- ##
==========================================
Coverage 15.08% 15.08% Complexity 11189 11189 ==========================================
Files 5406 5406 Lines 472828 472830 +2 Branches 59879 60053 +174 ==========================================
+ Hits 71346 71350 +4 + Misses 393537 393536 -1 + Partials 7945 7944 -1 
FlagCoverage Δ
uitests4.30% <ø> (ø)
unittests15.80% <0.00%> (+<0.01%)⬆️

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.

@blueorangutan

Copy link
Copy Markdown

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

@yadvryadvr added this to the 4.19.1.1 milestone Jul 29, 2024
@shwstppr

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@winterhazel

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@winterhazel 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.

@winterhazel

Copy link
Copy Markdown
MemberAuthor

@shwstppr could we run the CI again? There seems to have been a problem with the last run

@shwstppr

Copy link
Copy Markdown
Contributor

@winterhazel sure, will do that once we have the new packages

@blueorangutan

Copy link
Copy Markdown

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

@shwstppr

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@shwstppr

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File
test_01_secure_vm_migrationError133.32test_vm_life_cycle.py
test_01_secure_vm_migrationError133.33test_vm_life_cycle.py

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@yadvryadvr modified the milestones: 4.19.1.1, 4.19.2.0Aug 8, 2024
shwstpprand others added 2 commits August 11, 2024 17:45
* 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>
@shwstppr

Copy link
Copy Markdown
Contributor

@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]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10613

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File

@JoaoJandreJoaoJandre 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, did not test it.

@shwstpprshwstppr 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.

Code LGTM. Reported manual and smoke tests also look good.
It would be great if we could have some more manual QA

@shwstpprshwstppr removed their assignment Sep 4, 2024
@yadvr

yadvr commented Sep 5, 2024

Copy link
Copy Markdown
Member

cc @kiranchavala@rajujith@NuxRo@vladimirpetrov@borisstoyanov@JoaoJandre@GutoVeronezi or others - anybody able to manually QA this? Thanks.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland 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]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11027

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test keepEnv

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File
test_04_nonsecured_to_secured_vm_migrationError375.77test_vm_life_cycle.py

@DaanHoogland

Copy link
Copy Markdown
Contributor

@winterhazel , I tested very slightly (list networks does not give errors with no, or with an isolated and a shared network) but do not understand what the situation is you are trying to solve. Is there any specific situation I should test?

@winterhazel

winterhazel commented Sep 9, 2024

Copy link
Copy Markdown
MemberAuthor

Hey @DaanHoogland

When I opened this PR, the listNetworks filters were not working properly and allowed all users to see every network in the system (#9456).

This problem was introduced in an attempt to optimize the listNetworks queries (#9184) because the optimized query was not being generated as expected. I opened this PR to make it work as #9184 intended, and did some code clean-up.

However, #9184 was reverted in 4.19.1.1 (after I opened this), so the problem is not present anymore in the latest version. Hence, I adapted this PR to restore the optimizations made by #9184, but with the mentioned problem fixed and the clean-up done.

Therefore, we just need to test whether the listNetworks's response has not changed for the different filters.

@DaanHooglandDaanHoogland 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 (tested and reviewed)

@DaanHoogland
DaanHoogland merged commit a0932b0 into apache:4.19Sep 9, 2024
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Sep 23, 2024
Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
shwstppr added a commit to shwstppr/cloudstack that referenced this pull request Oct 13, 2024
Co-authored-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

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@winterhazel@blueorangutan@shwstppr@DaanHoogland@yadvr@JoaoJandre