Skip to content

Run ResourceCountCheckTask only in the longest running management server - #7977

Merged
yadvr merged 2 commits into
apache:mainfrom
shapeblue:fix-resource-count-task-blocks
Oct 12, 2023
Merged

yadvr merged 2 commits into
apache:mainfrom
shapeblue:fix-resource-count-task-blocks

Conversation

@nvazquez

@nvazquez nvazquez commented Sep 19, 2023 •

Copy link
Copy Markdown
Contributor

Description

This PR improves the DB locking on the ResourceLimitManager class, after observed issues on scaling.

This PR includes:

  • Making the ResourceCountCheckTask run only on the longest running management server
  • Do not recalculate the ROOT domain resource count before all the immediate children domains (in case of multi-level domains)

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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Tested on KVM with multiple management servers and 800+ level 2 domains

@nvazquez

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@codecov

codecov Bot commented Sep 19, 2023 •

Copy link
Copy Markdown

Codecov Report

Merging #7977 (8027ac5) into main (72cf974) will increase coverage by 1.81%.
Report is 17 commits behind head on main.
The diff coverage is 78.26%.

@@             Coverage Diff              @@
##               main    #7977      +/-   ##
============================================
+ Coverage     29.19%   31.01%   +1.81%     
+ Complexity    30460    30375      -85     
============================================
  Files          5101     4758     -343     
  Lines        358726   332912   -25814     
  Branches      52348    47906    -4442     
============================================
- Hits         104723   103242    -1481     
+ Misses       239643   215462   -24181     
+ Partials      14360    14208     -152     
Flag Coverage Δ
simulator-marvin-tests 25.05% <78.26%> (-0.09%) ⬇️
uitests ?
unit-tests 14.51% <0.00%> (+<0.01%) ⬆️

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

Files Coverage Δ
...cloud/cluster/dao/ManagementServerHostDaoImpl.java 40.14% <85.71%> (+2.36%) ⬆️
.../cloud/resourcelimit/ResourceLimitManagerImpl.java 69.83% <75.00%> (-3.98%) ⬇️

... and 403 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@nvazquez

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SF] 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 7064

@nvazquez

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

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

@blueorangutan

Copy link
Copy Markdown

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

Test Result Time (s) Test File
test_list_system_vms_metrics_history Failure 0.23 test_metrics_api.py
test_05_vmschedule_test_e2e Failure 260.87 test_vm_schedule.py

@DaanHoogland DaanHoogland 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, some comment though

@nvazquez
nvazquez force-pushed the fix-resource-count-task-blocks branch from 604c28b to b38976a Compare October 9, 2023 02:27
@nvazquez

nvazquez commented Oct 9, 2023

Copy link
Copy Markdown
Contributor Author

@DaanHoogland @shwstppr can you please re-review? The PR description is updated to match the current changes after the refactor

@nvazquez

nvazquez commented Oct 9, 2023

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SF] 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 7264

SearchCriteria<ManagementServerHostVO> sc = StateSearch.create();
sc.setParameters("state", ManagementServerHost.State.Up);
sc.setParameters("runid", 0);
Filter filter = new Filter(ManagementServerHostVO.class, "runid", true, 0L, 1L);

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.

so we order by runid and assume that means the first one is the longest running.
I think this will work, but there is the issue of re-joining the cluster and time skews (this is about milliseconds. I don´t think these will be issues for this functionality but just giving a heads-up. Maybe someone else knows??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In such cases would the runid field get updated? If that is the case then another management server will acquire the lock for this task

@nvazquez nvazquez changed the title Improve ResourceCountCheckTask and recalculation by not locking DB Run ResourceCountCheckTask only in the longest running management server Oct 11, 2023
@nvazquez

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@nvazquez a [SF] 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 7319

@yadvr
yadvr marked this pull request as ready for review October 11, 2023 15:20
@yadvr yadvr closed this Oct 11, 2023
@yadvr yadvr reopened this Oct 11, 2023
@yadvr

yadvr commented Oct 11, 2023

Copy link
Copy Markdown
Member

@blueorangutan test matrix

@blueorangutan

Copy link
Copy Markdown

@rohityadavcloud a [SF] Trillian-Jenkins matrix job (centos7 mgmt + xenserver71, rocky8 mgmt + vmware67u3, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

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

Test Result Time (s) Test File

@blueorangutan

Copy link
Copy Markdown

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

Test Result Time (s) Test File
test_08_upgrade_kubernetes_ha_cluster Failure 635.75 test_kubernetes_clusters.py
test_03_deploy_vm_wrong_checksum Error 41.56 test_templates.py
test_09_list_templates_download_details Failure 0.04 test_templates.py

@yadvr

yadvr commented Oct 12, 2023

Copy link
Copy Markdown
Member

Smoketests EL7 failures look intermittent and not related to this PR, let's kick after merging this on main health check PR.

@yadvr
yadvr merged commit dccd37a into apache:main Oct 12, 2023
@yadvr
yadvr deleted the fix-resource-count-task-blocks branch October 12, 2023 08:51
@blueorangutan

Copy link
Copy Markdown

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

Test Result Time (s) Test File
test_02_list_cpvm_vm Failure 0.04 test_ssvm.py
test_04_cpvm_internals Failure 0.05 test_ssvm.py
test_06_stop_cpvm Failure 0.05 test_ssvm.py
test_11_destroy_ssvm Failure 919.17 test_ssvm.py
test_12_destroy_cpvm Failure 920.90 test_ssvm.py
test_01_invalid_upgrade_kubernetes_cluster Failure 3623.24 test_kubernetes_clusters.py
test_02_upgrade_kubernetes_cluster Failure 3612.11 test_kubernetes_clusters.py
test_03_deploy_and_scale_kubernetes_cluster Failure 0.06 test_kubernetes_clusters.py
test_04_autoscale_kubernetes_cluster Failure 0.06 test_kubernetes_clusters.py
test_05_basic_lifecycle_kubernetes_cluster Failure 0.05 test_kubernetes_clusters.py
test_06_delete_kubernetes_cluster Failure 0.05 test_kubernetes_clusters.py
test_07_deploy_kubernetes_ha_cluster Failure 0.05 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Failure 0.06 test_kubernetes_clusters.py
test_09_delete_kubernetes_ha_cluster Failure 0.06 test_kubernetes_clusters.py
test_10_vpc_tier_kubernetes_cluster Failure 75.44 test_kubernetes_clusters.py
test_11_test_unmanaged_cluster_lifecycle Error 1.33 test_kubernetes_clusters.py
ContextSuite context=TestKubernetesCluster>:teardown Error 78.94 test_kubernetes_clusters.py
test_01_scale_up_verify Failure 576.63 test_vm_autoscaling.py
test_02_update_vmprofile_and_vmgroup Error 2.22 test_vm_autoscaling.py
test_03_scale_down_verify Error 1.08 test_vm_autoscaling.py
test_04_stop_remove_vm_in_vmgroup Error 3.31 test_vm_autoscaling.py

yildirimomer12 pushed a commit to yildirimomer12/cloudstack that referenced this pull request Jun 12, 2025
This adds the missing commit to the fix #335 from the upstream PR:
apache/cloudstack#7977

(cherry picked from commit b5f77f9c3b53af7e8b05730da9807a2c9eb017a5)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
Sign up for free to 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.

5 participants