cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Filter list VMs by IP address

Open Pearl1594 opened this issue 1 year ago • 4 comments

Description

This PR fixes: https://github.com/apache/cloudstack/issues/9486

Types of changes

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] New feature (non-breaking change which adds functionality)
  • [X] 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
  • [ ] test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • [ ] BLOCKER
  • [ ] Critical
  • [ ] Major
  • [X] Minor
  • [ ] Trivial

Screenshots (if appropriate):

How Has This Been Tested?

List VMs without any filter: image

Listing VMs with a specific IP: image

Listing VMs with a part of an IP used as filter: image

Listing VMs with an IP that doesn't match: image

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

Pearl1594 avatar Aug 19 '24 22:08 Pearl1594

Codecov Report

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

Project coverage is 15.24%. Comparing base (6e6a276) to head (b910bfe). Report is 57 commits behind head on 4.19.

Files with missing lines Patch % Lines
...c/main/java/com/cloud/utils/db/GenericDaoBase.java 0.00% 22 Missing :warning:
...ain/java/com/cloud/api/query/QueryManagerImpl.java 0.00% 13 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##               4.19    #9547      +/-   ##
============================================
+ Coverage     15.08%   15.24%   +0.15%     
- Complexity    11184    11572     +388     
============================================
  Files          5406     5406              
  Lines        472889   489497   +16608     
  Branches      57738    66537    +8799     
============================================
+ Hits          71352    74641    +3289     
- Misses       393593   406562   +12969     
- Partials       7944     8294     +350     
Flag Coverage Δ
uitests 5.10% <ø> (+0.79%) :arrow_up:
unittests 15.90% <0.00%> (+0.10%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 19 '24 22:08 codecov[bot]

@blueorangutan package

Pearl1594 avatar Aug 19 '24 23:08 Pearl1594

@Pearl1594 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 avatar Aug 19 '24 23:08 blueorangutan

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

blueorangutan avatar Aug 20 '24 00:08 blueorangutan

@vishesh92 @Pearl1594 is this ready or does it need more work?

DaanHoogland avatar Sep 20 '24 12:09 DaanHoogland

@DaanHoogland It works in the current state, but I wasn't able to address @vishesh92's comment, and am awaiting his response on it.

Pearl1594 avatar Sep 20 '24 14:09 Pearl1594

Every search with keyword param will become too expensive. We will be doing a join of user_vm table with user_vm_view which isn't a good idea. Let me spend some time on this next week.

vishesh92 avatar Sep 20 '24 14:09 vishesh92

@blueorangutan package

Pearl1594 avatar Sep 30 '24 10:09 Pearl1594

@Pearl1594 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 avatar Sep 30 '24 11:09 blueorangutan

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

blueorangutan avatar Sep 30 '24 11:09 blueorangutan

@blueorangutan test keepEnv

DaanHoogland avatar Oct 02 '24 07:10 DaanHoogland

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

blueorangutan avatar Oct 02 '24 07:10 blueorangutan

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

Test Result Time (s) Test File

blueorangutan avatar Oct 02 '24 21:10 blueorangutan

@vishesh92 could you please help review the changes made to address the discussed issue in the searchBuilder. Thanks!

Pearl1594 avatar Oct 04 '24 18:10 Pearl1594

Changes look good and it's working as expected. Just one case required to handle to prevent issues in future.

SQL query before

SELECT
    DISTINCT(user_vm.id)
FROM
    user_vm
    INNER JOIN vm_instance ON user_vm.id = vm_instance.id
    INNER JOIN account accountSearch ON vm_instance.account_id = accountSearch.id
    INNER JOIN vm_template vmTemplate ON vm_instance.vm_template_id = vmTemplate.id
WHERE
    vm_instance.type = 'User'
    AND vm_instance.display_vm = ?
    AND (
        user_vm.display_name LIKE ?
        OR vm_instance.name LIKE ?
        OR vm_instance.state = ?
        OR vm_instance.instance_name LIKE ?
    )
    AND vm_instance.removed IS NULL
    AND (accountSearch.type != ?)
    AND (vmTemplate.type != ?)
ORDER BY
    vm_instance.id ASC
LIMIT
    0, 20

after:

SELECT
    DISTINCT(user_vm.id)
FROM
    user_vm
    INNER JOIN vm_instance ON user_vm.id = vm_instance.id
    LEFT JOIN user_ip_address ipAddressSearch ON user_vm.id = ipAddressSearch.vm_id
    INNER JOIN vm_template vmTemplate ON vm_instance.vm_template_id = vmTemplate.id
    LEFT JOIN nics nicSearch ON user_vm.id = nicSearch.instance_id
    AND nicSearch.removed IS NULL
    INNER JOIN account accountSearch ON vm_instance.account_id = accountSearch.id
WHERE
    vm_instance.type = 'User'
    AND vm_instance.display_vm = ?
    AND (
        user_vm.display_name LIKE ?
        OR vm_instance.name LIKE ?
        OR vm_instance.state = ?
        OR vm_instance.instance_name LIKE ?
        OR ipAddressSearch.public_ip_address LIKE ?
        OR nicSearch.ip4_address LIKE ?
        OR nicSearch.ip4_address LIKE ?
    )
    AND vm_instance.removed IS NULL
    AND (vmTemplate.type != ?)
    AND (accountSearch.type != ?)
ORDER BY
    vm_instance.id ASC
LIMIT
    0, 20

vishesh92 avatar Oct 04 '24 21:10 vishesh92

@blueorangutan package

vishesh92 avatar Oct 07 '24 20:10 vishesh92

@vishesh92 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 avatar Oct 07 '24 20:10 blueorangutan

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

blueorangutan avatar Oct 07 '24 20:10 blueorangutan

@blueorangutan test

Pearl1594 avatar Oct 07 '24 21:10 Pearl1594

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

blueorangutan avatar Oct 07 '24 21:10 blueorangutan

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

Test Result Time (s) Test File

blueorangutan avatar Oct 08 '24 10:10 blueorangutan