You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "lucas-a-martins (via GitHub)" <gi...@apache.org> on 2024/08/07 21:48:25 UTC

[PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

lucas-a-martins opened a new pull request, #9500:
URL: https://github.com/apache/cloudstack/pull/9500

   ### Description
   
   This PR adds the following preset variables to the usage type `RUNNING_VM`:
   
   `value.computeOffering.offerHa`: A boolean informing if the compute offering offers HA or not.
   
   `configuration.forceHa`: A boolean informing if the cluster configuration `force.ha` is enabled or not. Considering that `force.ha` is a configuration at cluster scope, the priority is to get the value from the cluster. If no value is specified in the cluster scope, the variable will use the global settings value.
   
   ### 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)
   - [x] 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
   - [x] Minor
   
   
   ### Screenshots (if appropriate):
   
   ![offerHa](https://github.com/user-attachments/assets/57e12090-18dd-4b37-9886-c8bf8b0c1ab7)
   
   ### How Has This Been Tested?
   
   To test the `offerHa` variable, I created a VM using a compute offering where `offerHa=true` and the following tariff. As shown in the first screenshot above, the tariff was applied as expected.
   
   ```
   "activationRule": "value.computeOffering.offerHa",
   "currency": "$",
   "effectiveDate": "2024-08-05T20:35:26+0000",
   "id": "d8826c40-2063-4ceb-b377-b05cb8b72b6e",
   "name": "offerHa",
   "position": 1,
   "tariffValue": 30000,
   "usageDiscriminator": "None",
   "usageName": "RUNNING_VM",
   "usageType": 1,
   "usageTypeDescription": "Running Vm Usage",
   "usageUnit": "Compute*Month"
   ```
   
   Then, I tested the `forceHa` variable by using the following tariff:
   
   ```
   "activationRule": "configuration.forceHa",
   "currency": "$",
   "effectiveDate": "2024-08-05T19:25:17+0000",
   "id": "023d4562-7465-445c-afa7-cc356564ad98",
   "name": "forceHa",
   "position": 1,
   "tariffValue": 22222,
   "usageDiscriminator": "None",
   "usageName": "RUNNING_VM",
   "usageType": 1,
   "usageTypeDescription": "Running Vm Usage",
   "usageUnit": "Compute*Month"
   ```
   
   These are the results of my tests by changing the `force.ha` values in both the cluster and global settings:
   
   | Cluster | Global settings | Tariff applied |
   | ------ | ------ | ------ |
   |  _default_  |  _true_  | **Yes**|
   |  _true_  |  _false_ | **Yes**|
   |  _false_ |  _true_  |  **No** |
   |  _default_ |  _false_ |  **No** |


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "lucas-a-martins (via GitHub)" <gi...@apache.org>.
lucas-a-martins commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2486213365

   > there is a build error @lucas-a-martins , please have a look.
   
   Fixed, it was missing a import haha


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2284044036

   ## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/9500?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: Patch coverage is `90.00000%` with `5 lines` in your changes missing coverage. Please review.
   > Project coverage is 16.32%. Comparing base [(`cd8442a`)](https://app.codecov.io/gh/apache/cloudstack/commit/cd8442a42b65a3238c35f41f3ceac0e80e4df6c8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`96a5458`)](https://app.codecov.io/gh/apache/cloudstack/commit/96a54588af66648042efc16530f7e39f0691e5de?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 17 commits behind head on main.
   
   | [Files](https://app.codecov.io/gh/apache/cloudstack/pull/9500?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...tionrule/presetvariables/PresetVariableHelper.java](https://app.codecov.io/gh/apache/cloudstack/pull/9500?src=pr&el=tree&filepath=framework%2Fquota%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fcloudstack%2Fquota%2Factivationrule%2Fpresetvariables%2FPresetVariableHelper.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZnJhbWV3b3JrL3F1b3RhL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9jbG91ZHN0YWNrL3F1b3RhL2FjdGl2YXRpb25ydWxlL3ByZXNldHZhcmlhYmxlcy9QcmVzZXRWYXJpYWJsZUhlbHBlci5qYXZh) | 88.46% | [1 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/cloudstack/pull/9500?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [.../org/apache/cloudstack/quota/QuotaManagerImpl.java](https://app.codecov.io/gh/apache/cloudstack/pull/9500?src=pr&el=tree&filepath=framework%2Fquota%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fcloudstack%2Fquota%2FQuotaManagerImpl.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZnJhbWV3b3JrL3F1b3RhL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9jbG91ZHN0YWNrL3F1b3RhL1F1b3RhTWFuYWdlckltcGwuamF2YQ==) | 33.33% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/cloudstack/pull/9500?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #9500      +/-   ##
   ============================================
   + Coverage     15.54%   16.32%   +0.78%     
   - Complexity    11976    12005      +29     
   ============================================
     Files          5495     5123     -372     
     Lines        481076   450832   -30244     
     Branches      62235    54792    -7443     
   ============================================
   - Hits          74785    73613    -1172     
   + Misses       398028   369076   -28952     
   + Partials       8263     8143     -120     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/9500/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/9500/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/9500/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `16.32% <90.00%> (+0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/9500?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2543733281

   <b>[SF] Trillian test result (tid-11907)</b>
   Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
   Total time taken: 52891 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9500-t11907-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_unsecure_vm_migration | `Error` | 448.39 | test_vm_life_cycle.py
   test_03_secured_to_nonsecured_vm_migration | `Error` | 357.29 | test_vm_life_cycle.py
   


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "JoaoJandre (via GitHub)" <gi...@apache.org>.
JoaoJandre merged PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2543308113

   @blueorangutan test


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2543184471

   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2516395324

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


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "lucas-a-martins (via GitHub)" <gi...@apache.org>.
lucas-a-martins commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2625156325

   > [SF] Trillian test result (tid-11907) Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8 Total time taken: 52891 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9500-t11907-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_unsecure_vm_migration 	`Error` 	448.39 	test_vm_life_cycle.py
   > test_03_secured_to_nonsecured_vm_migration 	`Error` 	357.29 	test_vm_life_cycle.py
   
   I checked the test errors and both are unrelated with the PR


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2543274001

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


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2543184655

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


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2543308733

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


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#discussion_r1848155355


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/activationrule/presetvariables/PresetVariableHelper.java:
##########
@@ -389,12 +431,16 @@ protected String getPresetVariableValueOsName(Long guestOsId) {
         return guestOsVo.getDisplayName();
     }
 
-    protected ComputeOffering getPresetVariableValueComputeOffering(ServiceOfferingVO serviceOfferingVo) {
+    protected ComputeOffering getPresetVariableValueComputeOffering(ServiceOfferingVO serviceOfferingVo, int usageType) {
         ComputeOffering computeOffering = new ComputeOffering();
         computeOffering.setId(serviceOfferingVo.getUuid());
         computeOffering.setName(serviceOfferingVo.getName());
         computeOffering.setCustomized(serviceOfferingVo.isDynamic());
 
+        if (usageType == UsageTypes.RUNNING_VM) {

Review Comment:
   about time we change this to an enum. (no critique on this PR intended!)



-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#issuecomment-2485428130

   there is a build error @lucas-a-martins , please have a look.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add `offerHa` and `forceHa` preset variables to `RUNNING_VM` usage type [cloudstack]

Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on code in PR #9500:
URL: https://github.com/apache/cloudstack/pull/9500#discussion_r1846905527


##########
framework/quota/src/main/java/org/apache/cloudstack/quota/activationrule/presetvariables/PresetVariableHelper.java:
##########
@@ -271,6 +280,39 @@ protected GenericPresetVariable getPresetVariableZone(Long zoneId) {
         return zone;
     }
 
+    protected void setPresetVariableConfiguration(PresetVariables presetVariables, UsageVO usageRecord) {
+        if (usageRecord.getUsageType() != UsageTypes.RUNNING_VM) {
+            return;
+        }
+
+        Configuration configuration = new Configuration();
+        setForceHaInConfiguration(configuration, usageRecord);
+
+        presetVariables.setConfiguration(configuration);
+    }
+
+    protected void setForceHaInConfiguration(Configuration configuration, UsageVO usageRecord) {
+        Long vmId = usageRecord.getUsageId();
+        VMInstanceVO vmVo = vmInstanceDao.findByIdIncludingRemoved(vmId);
+        validateIfObjectIsNull(vmVo, vmId, "VM");
+
+        Long hostId = vmVo.getHostId() == null ? vmVo.getLastHostId() : vmVo.getHostId();

Review Comment:
   ```suggestion
           Long hostId = ObjectUtils.defaultIfNull(vmVo.getHostId(), vmVo.getLastHostId());
   ```



-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org