phsm opened a new pull request, #10221:
URL: https://github.com/apache/cloudstack/pull/10221

   ### Description
   
   This PR ensures that the cpu shares value is never < 2 to be compatible with 
Libvirt versions before 9.1.0.
   <!--- Describe your changes in DETAIL - And how has behaviour functionally 
changed. -->
   It turned out that the older libvirt versions, such as Ubuntu 22.04 libvirt 
8.0.0 has the hardcoded range of allowed cpu shares values for both cgroupv1 
and cgroupv2, which is 2-262144. 
   This range enforcement was removed in Libvirt 9.1.0, see: 
https://github.com/libvirt/libvirt/commit/38af6497610075e5fe386734b87186731d4c17ac
   
   If a host has lots of cores, and the huge CPU overprovisioning factor is 
set, then the computed shares value can become 1.
   In such case, the following exception is generated on the Cloudstack Agent 
during provisioning:
   `org.libvirt.LibvirtException: unsupported configuration: Value of cputune 
'shares' must be in range [2, 262144]`
   
   We noticed it when tried to restart a Shared network with cleanup.
   
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to 
reproduce. -->
   Steps to reproduce:
   1. Get a KVM hypervisor host with lots of cores.
   2. Make sure that cgroup v2 is enabled on the hypervisor: `mount | grep -q 
cgroup2 && echo "yes, enabled"` should echo the output.
   3. Set the overprovisioning ratio to some ridiculously high value, e.g. 1000
   4. Try to restart any network with cleanup. Since the virtual routers have 
tiny CPU specs (1 core, 500Mhz by default), it should trigger the bug. 
   5. The `com.cloud.exception.InsufficientServerCapacityException: No 
destination found for a deployment for VM instance` will be generated on the 
management server.
   6. On the agent, you will see the following message in the log: 
`org.libvirt.LibvirtException: unsupported configuration: Value of cputune 
'shares' must be in range [2, 262144]`
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be 
closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   <!-- Fixes: # -->
   
   <!--- 
******************************************************************************* 
-->
   <!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE 
DOCUMENTATION. -->
   <!--- PLEASE PUT AN 'X' in only **ONE** box -->
   <!--- 
******************************************************************************* 
-->
   
   ### 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
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [ ] Minor
   - [x] Trivial
   
   ### Screenshots (if appropriate):
   
   ### How Has This Been Tested?
   Tested on Ubuntu 22.04 with Libvirt 8.0.0.
   After the patch was applied, the error was gone, and the virtual router 
appeared after the restart with the cpushares value 2.
   
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to 
-->
   
   #### How did you try to break this feature and the system with this change?
   The only effective change that this change does, is excluding the return 
value "1". It is highly unlikely to break anything.
   
   <!-- see how your change affects other areas of the code, etc. -->
   
   <!-- Please read the 
[CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) 
document -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to