Skip to content

Refactor of Allocator classes - #9074

Merged
winterhazel merged 31 commits into
apache:mainfrom
scclouds:refactor-allocate-to-method
Apr 30, 2026
Merged

Refactor of Allocator classes#9074
winterhazel merged 31 commits into
apache:mainfrom
scclouds:refactor-allocate-to-method

Conversation

@BryanMLima

@BryanMLimaBryanMLima commented May 10, 2024

Copy link
Copy Markdown
Contributor

Description

This PR refactors some *Allocator classes, improving modularity and code legibility. This PR also made some changes to logs across these classes.

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

How Has This Been Tested?

I tested the allocation process in my personal lab, using both the RandomAllocator and FirstFitAllocator allocators. I tried some variation of tags and offerings, and everything looks good. Furthermore, I also added a lot of unit tests for the methods that I refactored.

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

@codecov

codecovBot commented May 10, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.75314% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.05%. Comparing base (856d83a) to head (803c3fa).
⚠️ Report is 5 commits behind head on main.

Files with missing linesPatch %Lines
...gent/manager/allocator/impl/FirstFitAllocator.java79.38%23 Missing and 4 partials ⚠️
.../agent/manager/allocator/impl/RandomAllocator.java89.09%6 Missing ⚠️
...agent/manager/allocator/impl/TestingAllocator.java0.00%3 Missing ⚠️
...om/cloud/deploy/DeploymentPlanningManagerImpl.java62.50%2 Missing and 1 partial ⚠️
...in/java/com/cloud/server/ManagementServerImpl.java0.00%3 Missing ⚠️
.../src/main/java/com/cloud/host/dao/HostDaoImpl.java0.00%2 Missing ⚠️
...i/command/admin/host/FindHostsForMigrationCmd.java0.00%1 Missing ⚠️
...loudstack/api/command/admin/host/ListHostsCmd.java0.00%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #9074 +/- ##
============================================
+ Coverage 18.01% 18.05% +0.03% - Complexity 16607 16653 +46 
============================================
Files 6029 6030 +1 Lines 542154 542077 -77 Branches 66451 66398 -53 ============================================
+ Hits 97681 97847 +166 + Misses 433457 433222 -235 + Partials 11016 11008 -8 
FlagCoverage Δ
uitests3.52% <ø> (ø)
unittests19.21% <80.75%> (+0.03%)⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

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

@BryanMLima
BryanMLimaforce-pushed the refactor-allocate-to-method branch from 537c10f to 952c273CompareJuly 15, 2024 13:26
@BryanMLimaBryanMLima changed the title Refactoring FirstFitAllocator classRefactoring Allocator classesJul 15, 2024
@BryanMLima
BryanMLima marked this pull request as ready for review July 15, 2024 13:44
@BryanMLimaBryanMLima changed the title Refactoring Allocator classesRefactor of Allocator classesJul 15, 2024
@BryanMLima
BryanMLima requested review from DaanHoogland and JoaoJandre and removed request for JoaoJandreJuly 15, 2024 13:45

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

LGTM, I did some basic testing, changed the allocator to FirstFit and created some VMs, the VM allocation worked fine with and without tags. However, my tests were limited, further testing would be good.

@BryanMLima
BryanMLimaforce-pushed the refactor-allocate-to-method branch 2 times, most recently from dd1eb14 to 952c273CompareJuly 24, 2024 14:28
@BryanMLima
BryanMLimaforce-pushed the refactor-allocate-to-method branch from 952c273 to b7cc66fCompareAugust 23, 2024 19:11
@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 10801

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan LLtest

@winterhazel

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with no 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 17525

@winterhazel

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

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

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

I went through the code again, and confirmed that it still looks good over 4.23. There was a mistake in the GPU-enabled host prioritization logic of the FirstFitAllocator which I fixed in the latest commits.

Also, I've done some testing with the FirstFit and Random allocators using distinct (i) host, template, and service offering tags (including tag rules) combinations, (ii) guest OS rules, and (iii) CPU and memory available on the hosts. I did not test the HVM and GPU filters/priorization, but the refactored code seems to have the same logic, and there's a good amount of unit tests for it.

@DaanHoogland I think that we can merge this one with regression tests. Could you run the CI one last time?

@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-15927)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 47940 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9074-t15927-kvm-ol8.zip
Smoke tests completed. 145 look OK, 3 have errors, 3 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
ContextSuite context=TestVPCRedundancy>:setupError0.00test_vpc_redundant.py
ContextSuite context=TestVPCNics>:setupError0.00test_vpc_router_nics.py
ContextSuite context=TestRVPCSite2SiteVpn>:setupError0.00test_vpc_vpn.py
ContextSuite context=TestVPCSite2SiteVPNMultipleOptions>:setupError0.00test_vpc_vpn.py
ContextSuite context=TestVpcRemoteAccessVpn>:setupError0.00test_vpc_vpn.py
ContextSuite context=TestVpcSite2SiteVpn>:setupError0.00test_vpc_vpn.py
all_test_webhook_deliverySkipped---test_webhook_delivery.py
all_test_webhook_lifecycleSkipped---test_webhook_lifecycle.py
all_test_host_maintenanceSkipped---test_host_maintenance.py

@winterhazel

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

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

@winterhazel

Copy link
Copy Markdown
Member

@DaanHoogland@sureshanaparti could we attempt another CI run here?

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-15945)

@winterhazel

Copy link
Copy Markdown
Member

@sureshanaparti looks like something went wrong with the CI. Could you have a look?

@sureshanaparti

Copy link
Copy Markdown
Contributor

@sureshanaparti looks like something went wrong with the CI. Could you have a look?

seems to be capacity issue, re-triggering...

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File
ContextSuite context=TestClusterDRS>:setupError0.00test_cluster_drs.py
test_list_system_vms_metrics_historyFailure0.60test_metrics_api.py

@winterhazel

Copy link
Copy Markdown
Member

Latest test failures seem unrelated and passed on #9074 (comment), so I am proceeding with the merge.

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.

8 participants

@BryanMLima@DaanHoogland@blueorangutan@JoaoJandre@winterhazel@sureshanaparti@harikrishna-patnala@weizhouapache