winterhazel opened a new pull request, #13025:
URL: https://github.com/apache/cloudstack/pull/13025
### Description
This PR adds the following preset variables to the secondary storage
selectors of `TEMPLATE` resources:
| Attribute | Description |
| ------ | ------ |
| `template.isPublic` | Whether the template is marked as public |
| `template.downloadDetails` | List containing information about the
template's state in each secondary storage that it is associated to |
| `template.downloadDetails[i].dataStoreId` | UUID of the secondary storage |
| `template.downloadDetails[i].downloadState` | Download state of template
in secondary storage |
Using them, it is possible to define heuristics to avoid the redownload/copy
of public templates, for instance:
```js
for (i = 0; i < template.downloadDetails.length; i++) {
details = template.downloadDetails[i];
if (template.isPublic && ['NOT_DOWNLOADED', 'DOWNLOAD_IN_PROGRESS',
'DOWNLOADED'].indexOf(details.downloadState) !== -1) {
details.dataStoreId;
break;
}
}
```
The selector above will direct the template to a secondary storage that the
template is already present when it is marked as public and
downloaded/downloading. Hence, it will not be duplicated to other secondary
storages.
### 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):
### How Has This Been Tested?
In an environment with a single secondary storage, `sec-nfs-1`:
1. I created a secondary storage selector for templates with the heuristic
rule available above.
2. I registered some public templates and waited until they finished
downloading to `sec-nfs-1`.
3. I added another secondary storage, `sec-nfs-2`, and verified that the
existing public templates were not copied/downloaded to `sec-nfs-2` because the
secondary storage selector was directing them to `sec-nfs-1`.
--
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]