Skip to content

vpc: optimize createMonitorServiceCommand() execution - #8385

Merged
weizhouapache merged 2 commits into
apache:4.18from
phsm:main
Feb 19, 2024
Merged

vpc: optimize createMonitorServiceCommand() execution#8385
weizhouapache merged 2 commits into
apache:4.18from
phsm:main

Conversation

@phsm

@phsmphsm commented Dec 20, 2023

Copy link
Copy Markdown
Contributor

Description

This PR moves an expensive getRouterHealthChecksConfig() upper the execution stack during VPC restart. So this way it is only executed once instead of tens or hundreds times (depending on VPC tiers amount).

This is done by introducing a Map<String, String> routerHealthCheckConfig argument to createMonitorServiceCommand() method that accepts pre-computed health check config.

Fixes#8055

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?

  1. Prepared a test VPC:
  • 10 tiers
  • redundant offering (2 VRs)
  • each tier has 1 running VM in it.
  1. Performed VPC restart with clean up. Took 61 minutes to fully restart in my case
  2. Applied these changes
  3. Performed VPC restart with clean up. Took 9 minutes to fully restart.

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

@boring-cyborg

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
Here are some useful points:

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@codecov

codecovBot commented Dec 20, 2023

Copy link
Copy Markdown

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (e47a910) 13.16% compared to head (3c5fc9d) 30.74%.

FilesPatch %Lines
...ork/router/VirtualNetworkApplianceManagerImpl.java71.42%1 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## 4.18 #8385 +/- ##
=============================================
+ Coverage 13.16% 30.74% +17.58% - Complexity 9203 33064 +23861 
=============================================
Files 2724 5353 +2629 Lines 258120 374609 +116489 Branches 40231 54635 +14404 =============================================
+ Hits 33989 115188 +81199 - Misses 219823 244149 +24326 - Partials 4308 15272 +10964 
FlagCoverage Δ
simulator-marvin-tests24.59% <77.77%> (?)
uitests4.38% <ø> (?)
unit-tests16.43% <0.00%> (?)

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

@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 8103

@harikrishna-patnala

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@harikrishna-patnalaharikrishna-patnala 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.

results seems to be very interesting @phsm

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File
test_05_list_volumes_isrecursiveFailure0.03test_list_volumes.py
test_07_list_volumes_listallFailure0.02test_list_volumes.py

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

Code LGTM

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

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

code lgtm

@blueorangutan

Copy link
Copy Markdown

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

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti 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-8666)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 49046 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8385-t8666-kvm-centos7.zip
Smoke tests completed. 121 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File

@phsm

phsm commented Jan 11, 2024

Copy link
Copy Markdown
ContributorAuthor

Is there anything else that I can do for this PR to be merged? I see some tests are failed but my Java knowledge isn't that great to actually fix them so I'd appreciate any help on this.

@weizhouapache

Copy link
Copy Markdown
Member

Is there anything else that I can do for this PR to be merged? I see some tests are failed but my Java knowledge isn't that great to actually fix them so I'd appreciate any help on this.

@DaanHoogland@shwstppr can you please review ?

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

clgtm, not sure what we need to test for this (assuming the smoke tests have tested health check functionality)

@phsm

phsm commented Feb 2, 2024

Copy link
Copy Markdown
ContributorAuthor

So, can this PR be merged if everyone approves? :)

@weizhouapache

Copy link
Copy Markdown
Member

So, can this PR be merged if everyone approves? :)

Not yet.
Needs someone to manually test it

@DaanHooglandDaanHoogland added this to the 4.20.0.0 milestone Feb 3, 2024
@weizhouapache
weizhouapache changed the base branch from main to 4.19February 15, 2024 09:15
@weizhouapacheweizhouapache removed this from the 4.20.0.0 milestone Feb 15, 2024
@DaanHooglandDaanHoogland added this to the 20.0.0 milestone Feb 15, 2024
@DaanHoogland

Copy link
Copy Markdown
Contributor

@phsm I think you wanted to rebase your commit onto 4.18, did you?

@weizhouapache

Copy link
Copy Markdown
Member

@phsm
please try the following commands

git fetch apache
git checkout apache/4.18
git branch -D main
git checkout -b main
git cherry-pick e34959fe66f6078b259041bd8023a1f73dec0a3c
git cherry-pick b6b7d47089d39f10712c027826ee0de830d6d9e0
git push origin main -f

Avoid an expensive getRouterHealthChecksConfig() execution multiple times during VPC restart.
Fixes#8055
@phsm
phsm changed the base branch from main to 4.18February 15, 2024 12:40
@phsm

phsm commented Feb 15, 2024

Copy link
Copy Markdown
ContributorAuthor

@phsm please try the following commands

git fetch apache
git checkout apache/4.18
git branch -D main
git checkout -b main
git cherry-pick e34959fe66f6078b259041bd8023a1f73dec0a3c
git cherry-pick b6b7d47089d39f10712c027826ee0de830d6d9e0
git push origin main -f

Thanks, that seems to have worked.

@DaanHooglandDaanHoogland modified the milestones: 20.0.0, 4.18.2.0Feb 15, 2024
@vishesh92

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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

Copy link
Copy Markdown

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

@vishesh92

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@vishesh92 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-9247)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 42810 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8385-t9247-kvm-centos7.zip
Smoke tests completed. 107 look OK, 3 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
test_10_reboot_cpvm_forcedError6.24test_ssvm.py
test_08_migrate_vmError0.05test_vm_life_cycle.py
test_01_redundant_vpc_site2site_vpnFailure590.97test_vpc_vpn.py
test_01_vpc_site2site_vpn_multiple_optionsFailure469.91test_vpc_vpn.py
test_01_vpc_site2site_vpnFailure287.80test_vpc_vpn.py

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan test rocky8 kvm-rocky8

@blueorangutan

Copy link
Copy Markdown

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

@vishesh92

Copy link
Copy Markdown
Member

@blueorangutan test rocky8 kvm-rocky8

@blueorangutan

Copy link
Copy Markdown

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

@vishesh92

Copy link
Copy Markdown
Member

Tested these changes. I couldn't find any difference in performance for these changes. I followed these steps:

  1. Setup 2 envs (with and without this patch)
  2. Create a VPC with redundant offering
  3. Add 10 networks and launch 1 VM in each
  4. Restarted VPC with cleanup
  5. Check the difference in created, removed in async_job table for VPCRestartCmd

@phsm

phsm commented Feb 19, 2024

Copy link
Copy Markdown
ContributorAuthor

Tested these changes. I couldn't find any difference in performance for these changes. I followed these steps:

1. Setup 2 envs (with and without this patch)
2. Create a VPC with redundant offering
3. Add 10 networks and launch 1 VM in each
4. Restarted VPC with cleanup
5. Check the difference in created, removed in async_job table for VPCRestartCmd

Hi,
As I mentioned earlier, this is only reproducible on CS installations "with history", i.e. with a large cloudstack database with a lot of both running and removed services (VMs, networks, VPCs etc).
Only then the getRouterHealthChecksConfig() takes 1-2 seconds to complete, which with combination of hundreds of this method executions adds a significant time to the process.

@weizhouapache

Copy link
Copy Markdown
Member

Tested these changes. I couldn't find any difference in performance for these changes. I followed these steps:

  1. Setup 2 envs (with and without this patch)
  2. Create a VPC with redundant offering
  3. Add 10 networks and launch 1 VM in each
  4. Restarted VPC with cleanup
  5. Check the difference in created, removed in async_job table for VPCRestartCmd

@vishesh92
it is probably because our database is too small.
if the platforms have been running for many years (for example, more than 5), it could make big difference.

considering this is an optimization, it looks there is no regression (in manual and smoke tests), can we say it is good to merge ? @vishesh92

@vishesh92

Copy link
Copy Markdown
Member

@weizhouapache@phsm Got it. It is good to merge from my side.

For manual testing, I just did what I mentioned in the above steps and tried to connect VMs I launched.

@weizhouapache

Copy link
Copy Markdown
Member

@weizhouapache@phsm Got it. It is good to merge from my side.

For manual testing, I just did what I mentioned in the above steps and tried to connect VMs I launched.

thanks @vishesh92 for the testing

I will merge it then

@weizhouapache
weizhouapache merged commit af942e2 into apache:4.18Feb 19, 2024
@boring-cyborg

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request!

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File

dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Mar 5, 2024
* Optimize createMonitorServiceCommand() execution.
Avoid an expensive getRouterHealthChecksConfig() execution multiple times during VPC restart.
Fixesapache#8055
* Move getRouterHealthChecksConfig() outside of loop
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.

Backup virtual router of a redundant VPC stays in starting state after restart with clean up.

7 participants

@phsm@DaanHoogland@weizhouapache@blueorangutan@harikrishna-patnala@sureshanaparti@vishesh92