Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor of Allocator classes #9074

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

BryanMLima
Copy link
Contributor

@BryanMLima BryanMLima commented May 10, 2024

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?

Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 68.89764% with 79 lines in your changes missing coverage. Please review.

Project coverage is 15.85%. Comparing base (1d4700a) to head (b93e998).

Files with missing lines Patch % Lines
...gent/manager/allocator/impl/FirstFitAllocator.java 60.26% 58 Missing and 2 partials ⚠️
.../agent/manager/allocator/impl/RandomAllocator.java 84.48% 9 Missing ⚠️
...agent/manager/allocator/impl/TestingAllocator.java 0.00% 3 Missing ⚠️
...in/java/com/cloud/server/ManagementServerImpl.java 0.00% 3 Missing ⚠️
.../src/main/java/com/cloud/host/dao/HostDaoImpl.java 0.00% 2 Missing ⚠️
...i/command/admin/host/FindHostsForMigrationCmd.java 0.00% 1 Missing ⚠️
...loudstack/api/command/admin/host/ListHostsCmd.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9074      +/-   ##
============================================
+ Coverage     15.81%   15.85%   +0.04%     
- Complexity    12554    12601      +47     
============================================
  Files          5629     5630       +1     
  Lines        492029   491963      -66     
  Branches      62293    63884    +1591     
============================================
+ Hits          77811    77999     +188     
+ Misses       405894   405642     -252     
+ Partials       8324     8322       -2     
Flag Coverage Δ
uitests 4.48% <ø> (ø)
unittests 16.64% <68.89%> (+0.04%) ⬆️

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.

Copy link

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

Copy link

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

@BryanMLima BryanMLima changed the title Refactoring FirstFitAllocator class Refactoring Allocator classes Jul 15, 2024
@BryanMLima BryanMLima marked this pull request as ready for review July 15, 2024 13:44
@BryanMLima BryanMLima changed the title Refactoring Allocator classes Refactor of Allocator classes Jul 15, 2024
@BryanMLima BryanMLima requested review from JoaoJandre and DaanHoogland and removed request for JoaoJandre July 15, 2024 13:45
import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;

public class TestingAllocator extends AdapterBase implements HostAllocator {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this not a BaseAllocator-child, @BryanMLima ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DaanHoogland, because TestingAllocator does not have any methods in common with BaseAllocator. Is there a reason that it should extend it?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, but it seems an outlier and the name also suggests it is intended to be a mock version for testing what would make less sense if it is not based on the same. I'd have to study it's use to give a definite answer.

Copy link
Contributor

@JoaoJandre JoaoJandre left a comment

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 BryanMLima force-pushed the refactor-allocate-to-method branch 2 times, most recently from dd1eb14 to 952c273 Compare July 24, 2024 14:28
@DaanHoogland
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@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

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

@DaanHoogland
Copy link
Contributor

@blueorangutan LLtest

@blueorangutan
Copy link

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

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_01_isolate_network_FW_PF_default_routes_egress_true Failure 110.59 test_routers_network_ops.py
test_02_restore_vm_strict_tags_failure Failure 58.19 test_vm_strict_host_tags.py
test_02_scale_vm_strict_tags_failure Failure 60.31 test_vm_strict_host_tags.py
test_06_deploy_vm_on_any_host_with_strict_tags_failure Failure 5.54 test_vm_strict_host_tags.py
test_hostha_enable_ha_when_host_disabled Error 3.93 test_hostha_kvm.py
test_hostha_enable_ha_when_host_in_maintenance Error 302.07 test_hostha_kvm.py

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm

@DaanHoogland DaanHoogland added this to the 4.20.0.0 milestone Sep 10, 2024
@boring-cyborg boring-cyborg bot added component:integration-test Python Warning... Python code Ahead! labels Sep 10, 2024
@BryanMLima
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@BryanMLima
Copy link
Contributor Author

@DaanHoogland, could you trigger the smoke tests again? The failed tests in test_vm_strict_host_tags.py were related to the exception message, it should be fixed now. The others do not seem to be related to this PR.

@blueorangutan
Copy link

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

@JoaoJandre JoaoJandre modified the milestones: 4.20.0.0, 4.21.0.0 Sep 10, 2024
@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_02_restore_vm_strict_tags_failure Failure 52.04 test_vm_strict_host_tags.py
test_02_scale_vm_strict_tags_failure Failure 55.24 test_vm_strict_host_tags.py

@BryanMLima
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

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

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.

4 participants