-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add dynamic secondary storage selection #7659
Conversation
@blueorangutan package |
@DaanHoogland a [SF] 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. |
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6283 |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #7659 +/- ##
=============================================
+ Coverage 18.25% 28.93% +10.68%
- Complexity 17824 31007 +13183
=============================================
Files 5100 5251 +151
Lines 346393 368752 +22359
Branches 49768 53759 +3991
=============================================
+ Hits 63217 106682 +43465
+ Misses 274118 247425 -26693
- Partials 9058 14645 +5587
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
...pache/cloudstack/api/command/admin/storage/heuristics/CreateSecondaryStorageSelectorCmd.java
Outdated
Show resolved
Hide resolved
...pache/cloudstack/api/command/admin/storage/heuristics/UpdateSecondaryStorageSelectorCmd.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/apache/cloudstack/api/response/SecondaryStorageHeuristicsResponse.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/apache/cloudstack/secstorage/heuristics/Heuristic.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/apache/cloudstack/secstorage/heuristics/HeuristicPurpose.java
Outdated
Show resolved
Hide resolved
engine/schema/src/main/java/org/apache/cloudstack/secstorage/HeuristicVO.java
Outdated
Show resolved
Hide resolved
.../schema/src/main/java/org/apache/cloudstack/secstorage/dao/SecondaryStorageHeuristicDao.java
Outdated
Show resolved
Hide resolved
...ema/src/main/java/org/apache/cloudstack/secstorage/dao/SecondaryStorageHeuristicDaoImpl.java
Outdated
Show resolved
Hide resolved
engine/schema/src/main/resources/META-INF/db/schema-41810to41900.sql
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/cloudstack/storage/heuristics/HeuristicRuleHelper.java
Outdated
Show resolved
Hide resolved
...org/apache/cloudstack/storage/heuristics/presetvariables/GenericHeuristicPresetVariable.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/cloudstack/storage/heuristics/presetvariables/PresetVariables.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/apache/cloudstack/storage/heuristics/presetvariables/SecondaryStorage.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/cloudstack/storage/heuristics/presetvariables/Snapshot.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/cloudstack/storage/heuristics/presetvariables/Template.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/cloudstack/storage/heuristics/presetvariables/Volume.java
Outdated
Show resolved
Hide resolved
hey @BryanMLima , I saw the issue with functional description that came with this. I haven't yet read it and just reacted to the lint output:
|
Thanks, I always forget about these. |
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm.
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
@BryanMLima , conflict :( can you resolve it? |
@BryanMLima any documentation available that provides some guidance on the usage of this feature? Any plans to implement a UI? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I could dedicate a secondary storage for KVM snapshots.
- I could dedicate a secondary storage for a domain.
- I was unable to dedicate another secondary storage for a second domain in the same zone. I believe this might be a limitation?
- I faced the below issues while registering template with the following rules:
(SS-SelectorPR) 🐱 > create secondarystorageselector name=KVMtemplatesonly description=KVMtemplatesonly type=TEMPLATE zoneid=a2a9fafd-43fb-4508-915e-d3c836a7e972 heuristicrule="function directToDedicatedQCOW2Pool(pool) {return pool.uuid === '92dc82ff-c3cc-4756-928f-6802c358f599';} if (template.format === 'QCOW2') {secondaryStorages.filter(directToDedicatedQCOW2Pool)[0].uuid}"
{
"heuristics": {
"created": "2023-11-15T11:42:50+0000",
"description": "KVMtemplatesonly",
"heuristicrule": "function directToDedicatedQCOW2Pool(pool) {return pool.uuid === '92dc82ff-c3cc-4756-928f-6802c358f599';} if (template.format === 'QCOW2') {secondaryStorages.filter(directToDedicatedQCOW2Pool)[0].uuid}",
"id": "1d9070e9-5d12-4159-9e7c-de0793c87e24",
"name": "KVMtemplatesonly",
"type": "TEMPLATE",
"zoneid": "a2a9fafd-43fb-4508-915e-d3c836a7e972"
}
}
On register template:
due to [javax.script.ScriptException: TypeError: Cannot read property "uuid" from undefined in <eval> at line number 1]
at org.apache.cloudstack.utils.jsinterpreter.JsInterpreter.executeScriptInThread(JsInterpreter.java:121)
Specific UUID:
create secondarystorageselector name=KVMtemplatesonly-specifc description=KVMtemplatesonly-specific type=TEMPLATE zoneid=a2a9fafd-43fb-4508-915e-d3c836a7e972 heuristicrule="function findStorageWithSpecificUuid(pool) { return pool.uuid === '92dc82ff-c3cc-4756-928f-6802c358f599'; } secondaryStorages.filter(findStorageWithSpecificUuid)[0].uuid"
On register template:
java.util.concurrent.ExecutionException: javax.script.ScriptException: TypeError: Cannot read property "uuid" from undefined in <eval> at line number 1
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
@rajujith currently, the only documentation (more like a feature specification) is described in issue #7654; though, I pretend to add a proper documentation of this feature in the official documentation of CloudStack. Regarding the implementation of the UI for this feature, it is planned, however, it is not a priority at the moment.
@rajujith thanks for testing this PR. Regarding item 3), could you provide more details of this testing? This feature only allows one heuristic rule per type, if you tried to dedicate a secondary storage to a domain for a specific type, you need to edit the same heuristic rule to dedicate to another domain. In the future, this feature could allow multiple heuristic rules for the same type in a zone, allowing operators to specify the order in which each rule would be verified. Regarding item 4), the description of this PR and the issue presented the |
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
@blueorangutan package |
@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. |
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7892 |
@blueorangutan rest |
Even the CI needs to rest a bit, right? 😂 |
@blueorangutan test |
@vishesh92 a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
[SF] Trillian test result (tid-8451)
|
@BryanMLima I updated the rules for scenarios 3) and 4). Now they are working fine. list secondarystorageselectors zoneid=a2a9fafd-43fb-4508-915e-d3c836a7e972 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Description
This PR aims to add the possibility to direct resources (Volumes, Templates, Snapshots and ISOs) to a specific secondary storage through rules written in JavaScript that will only affect new allocated resources. This feature is fully described in issue #7654.
Fixes: #7654
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
How Has This Been Tested?
Unit tests were added to validate the functionality of the implemented methods. Besides this, the overall functionality was tested in a local lab with two secondary storage available, creating basic JS rules and validating that the resource was allocated according to the heuristic rule. Below, there are some examples used in the tests, based on the variables available for each resource type specified in the specification of the feature proposal.