You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "winterhazel (via GitHub)" <gi...@apache.org> on 2023/10/24 17:23:20 UTC
[PR] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
winterhazel opened a new pull request, #8138:
URL: https://github.com/apache/cloudstack/pull/8138
### Description
This PR adds two new preset variables into the Quota activation rules: hypervisor type and volume format. This allows operators to customize tariffs based on these two properties.
The respective preset variable will be injected into tariffs with the following usage types:
- RUNNING_VM: `value.hypervisorType`;
- ALLOCATED_VM: `value.hypervisorType`;
- VM_SNAPSHOT: `value.hypervisorType`;
- SNAPSHOT: `value.hypervisorType`;
- VOLUME: `value.volumeFormat`;
- VOLUME_SECONDARY: `value.volumeFormat`.
Example of an activation rule using `value.hypervisorType`:
```js
if (value.hypervisorType=='KVM') {
1
} else {
2
}
```
Example of an activation rule using `value.volumeFormat`:
```js
if (value.volumeFormat=='QCOW2') {
3
} else {
4
}
```
Furthermore, this PR also fixes the preset variable `resourceType` being injected into the JavaScript interpreter without quotes, which prevented the activation rules from executing.
```
2023-10-05 16:43:08,886 ERROR [o.a.c.q.QuotaManagerImpl] (qtp1955920234-22:ctx-d90594cb ctx-6d904941) (logid:5f086162) Failed to calculate the quota usage for account [{"accountName":"fabricio","domainId":1,"id":21,"uuid":"ae254524-854a-4049-9d1b-721cfaffdd71"}] due to [Unable to execute script [ account = {"role":{"type":"User","id":"64b4ca77-26de-11ec-8dcf-5254005dcdac","name":"User"},"id":"ae254524-854a-4049-9d1b-721cfaffdd71","name":"fabricio"}; domain = {"path":"\/","id":"52d83793-26de-11ec-8dcf-5254005dcdac","name":"ROOT"}; resourceType = KVM; value = {"accountResources":[{"domainId":"52d83793-26de-11ec-8dcf-5254005dcdac","zoneId":"8b2ceb16-a2f2-40ea-8968-9e08984bdb17"},{"domainId":"52d83793-26de-11ec-8dcf-5254005dcdac","zoneId":"8b2ceb16-a2f2-40ea-8968-9e08984bdb17"},{"domainId":"52d83793-26de-11ec-8dcf-5254005dcdac","zoneId":"8b2ceb16-a2f2-40ea-8968-9e08984bdb17"}],"computeOffering":{"customized":false,"id":"ab647165-7a0a-4984-8452-7bfceb036528","name":"Small Instance"},"c
omputingResources":{"cpuNumber":1,"cpuSpeed":500,"memory":512},"host":{"tags":[],"id":"3d7d8532-d0cf-476c-a36e-1b936d780abb","name":"cloudstack-lab-host-2"},"hypervisorType":"KVM","osName":"Ubuntu 18.04 LTS","tags":{},"template":{"id":"bb4b7b6f-5249-4c18-a5f6-dd886683b702","name":"Ubuntu Bionic"},"id":"a83ece0c-58e7-4bc5-8564-f70fe8e34fc0","name":"t2"}; zone = {"id":"8b2ceb16-a2f2-40ea-8968-9e08984bdb17","name":"sc-floripa-01"}; if (value.hypervisorType=='KVM') { 1 } else { 2 }] due to [javax.script.ScriptException: ReferenceError: "KVM" is not defined in <eval> at line number 1]].
```
### 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)
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [ ] Major
- [X] Minor
#### Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [X] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
I created two tariffs through CloudMonkey:
```
(admin) 🐱 > quota tariffcreate activationrule="if (value.hypervisorType=='KVM') { 1 } else { 2 }" usagetype=1 value=0 name="hypervisor" description="hypervisor"
{
"quotatariff": {
"activationRule": "if (value.hypervisorType=='KVM') { 1 } else { 2 }",
"currency": "$",
"description": "hypervisor",
"effectiveDate": "2023-10-04T21:46:19+0000",
"name": "hypervisor",
"tariffValue": 0,
"usageDiscriminator": "None",
"usageName": "RUNNING_VM",
"usageType": 1,
"usageTypeDescription": "Running Vm Usage",
"usageUnit": "Compute*Month",
"uuid": "85941d4b-cc6e-4e18-ba85-7708ea3a41eb"
}
}
(admin) 🐱 > quota tariffcreate activationrule="if (value.volumeFormat=='QCOW2') { 3 } else { 4 }" usagetype=6 value=0 name="volume format" description="volume format"
{
"quotatariff": {
"activationRule": "if (value.volumeFormat=='QCOW2') { 3 } else { 4 }",
"currency": "$",
"description": "volume format",
"effectiveDate": "2023-10-04T21:48:42+0000",
"name": "volume format",
"tariffValue": 0,
"usageDiscriminator": "None",
"usageName": "VOLUME",
"usageType": 6,
"usageTypeDescription": "Volume Usage",
"usageUnit": "GB*Month",
"uuid": "7b6c9eae-b369-40b7-adc3-0add4abf27bd"
}
}
```
Then, I deployed a virtual machine using KVM, called `quotaUpdate` and verified through the logs that that the calculated value was 1 for the first tariff and 3 for the second.
--
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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "GutoVeronezi (via GitHub)" <gi...@apache.org>.
GutoVeronezi commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1788038545
> > > the gha failure is codecov upload. I don't think the ssvm errors are related. @shwstppr @GutoVeronezi Are we requiring 3rd party testing on this?
> >
> >
> > It would be interesting to have 3rd party testing.
>
> I am not using quota, do you have a suggestion for who could test this, @GutoVeronezi ?
@DaanHoogland I'll ask someone to test this.
--
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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1779165531
@DaanHoogland a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) 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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "GutoVeronezi (via GitHub)" <gi...@apache.org>.
GutoVeronezi commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1783235180
> the gha failure is codecov upload. I don't think the ssvm errors are related. @shwstppr @GutoVeronezi Are we requiring 3rd party testing on this?
It would be interesting to have 3rd party testing.
--
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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1779028015
@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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1788664467
> > I am not using quota, do you have a suggestion for who could test this, @GutoVeronezi ?
>
> @DaanHoogland, maybe @hsato03 could test it.
thanks guys
--
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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1779036726
@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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1779162035
@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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1782473706
the gha failure is codecov upload. I don't think the ssvm errors are related. @shwstppr @GutoVeronezi Are we requiring 3rd party testing on this?
--
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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland merged PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138
--
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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1779048061
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/8138?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#8138](https://app.codecov.io/gh/apache/cloudstack/pull/8138?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (3af5b4c) into [main](https://app.codecov.io/gh/apache/cloudstack/commit/543c54c7189937fe15e2c74db2277795e13a7a1c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (543c54c) will **decrease** coverage by `23.37%`.
> Report is 4 commits behind head on main.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## main #8138 +/- ##
============================================
- Coverage 28.15% 4.79% -23.37%
============================================
Files 5111 345 -4766
Lines 360669 26102 -334567
Branches 52700 4493 -48207
============================================
- Hits 101562 1252 -100310
+ Misses 245113 24715 -220398
+ Partials 13994 135 -13859
```
| [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/8138/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [simulator-marvin-tests](https://app.codecov.io/gh/apache/cloudstack/pull/8138/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/8138/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.79% <ø> (ø)` | |
| [unit-tests](https://app.codecov.io/gh/apache/cloudstack/pull/8138/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
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.
[see 4766 files with indirect coverage changes](https://app.codecov.io/gh/apache/cloudstack/pull/8138/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1780561398
<b>[SF] Trillian test result (tid-8095)</b>
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 45061 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8138-t8095-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_02_list_cpvm_vm | `Failure` | 0.05 | test_ssvm.py
test_04_cpvm_internals | `Failure` | 0.03 | test_ssvm.py
test_12_destroy_cpvm | `Error` | 3.15 | test_ssvm.py
test_08_upgrade_kubernetes_ha_cluster | `Failure` | 677.58 | test_kubernetes_clusters.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] Inject hypervisor type and volume format on Quota tariffs [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #8138:
URL: https://github.com/apache/cloudstack/pull/8138#issuecomment-1787471693
> > the gha failure is codecov upload. I don't think the ssvm errors are related. @shwstppr @GutoVeronezi Are we requiring 3rd party testing on this?
>
> It would be interesting to have 3rd party testing.
I am not using quota, do you have a suggestion for who could test this, @GutoVeronezi ?
--
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