You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "rp- (via GitHub)" <gi...@apache.org> on 2025/01/27 12:42:05 UTC
[PR] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
rp- opened a new pull request, #10280:
URL: https://github.com/apache/cloudstack/pull/10280
### Description
It should have been always possible to use multiple primary storages, with the same linstor-controller, by just using different resource-groups with different settings.
But if the same template was used on 2 different primary storages, there would be a name collision on the linstor-controller, as 2 of them would get allocated to the same name.
This commit fixes this, by intelligently reusing the same template, as long as possible (if select filter properties match enough).
<!--- ******************************************************************************* -->
<!--- 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
- [x] Major
- [ ] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
* Integration tests run
* Linstor cluster used by 3 different primary storage(same CS cluster) + let cleanup storage run
#### How did you try to break this feature and the system with this change?
<!-- 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: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2615732573
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2615730327
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "rp- (via GitHub)" <gi...@apache.org>.
rp- commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2635994484
> @rp- can you have another look? (conflicts)
already on it
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2615866219
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12221
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2618096529
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2618214582
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12234
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2616007324
<b>[SF] Trillian Build Failed (tid-12195)<b/>
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "rp- (via GitHub)" <gi...@apache.org>.
rp- commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2621104943
> LGTM, I've not tested this though.
>
> @rp- I hope you must have covered the template deletion part. If not, please verify once.
I did, I tested with 3 primary storages using the same linstor cluster.
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2637106001
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2636906737
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12345
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2637103732
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2636794420
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2618312635
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2615908962
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2618099300
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2617744903
<b>[LL]Trillian test result (tid-7069)</b>
Environment: kvm-rocky8 (x2), Advanced Networking with Mgmt server r8
Total time taken: 40756 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10280-t7069-kvm-rocky8.zip
Smoke tests completed. 133 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2615910423
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2635569159
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2635991364
@rp- can you have another look? (conflicts)
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2618304408
@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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#discussion_r1930502892
##########
plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java:
##########
@@ -475,16 +486,39 @@ public boolean deletePhysicalDisk(String name, KVMStoragePool pool, Storage.Imag
{
s_logger.debug("Linstor: deletePhysicalDisk " + name);
final DevelopersApi api = getLinstorAPI(pool);
-
+ final String rscName = getLinstorRscName(name);
+ final LinstorStoragePool linstorPool = (LinstorStoragePool) pool;
+ String rscGrpName = linstorPool.getResourceGroup();
+ boolean deleted = false;
try {
- final String rscName = getLinstorRscName(name);
- s_logger.debug("Linstor: delete resource definition " + rscName);
- ApiCallRcList answers = api.resourceDefinitionDelete(rscName);
- handleLinstorApiAnswers(answers, "Linstor: Unable to delete resource definition " + rscName);
+ List<ResourceDefinition> existingRDs = LinstorUtil.getRDListStartingWith(api, rscName);
+
+ for (ResourceDefinition rd : existingRDs) {
+ int expectedProps = 0; // if it is a non template resource, we don't expect any _cs-template-for- prop
+ String propKey = LinstorUtil.getTemplateForAuxPropKey(rscGrpName);
+ if (rd.getProps().containsKey(propKey)) {
+ ResourceDefinitionModify rdm = new ResourceDefinitionModify();
+ rdm.deleteProps(Collections.singletonList(propKey));
+ api.resourceDefinitionModify(rd.getName(), rdm);
+ expectedProps = 1;
+ }
+
+ // if there is only one template-for property left for templates, the template isn't needed anymore
+ // or if it isn't a template anyway, it will not have this Aux property
+ // _cs-template-for- poperties work like a ref-count.
+ if (rd.getProps().keySet().stream()
+ .filter(key -> key.startsWith("Aux/" + LinstorUtil.CS_TEMPLATE_FOR_PREFIX))
+ .count() == expectedProps) {
+ ApiCallRcList answers = api.resourceDefinitionDelete(rd.getName());
+ checkLinstorAnswersThrow(answers);
+ deleted = true;
+ }
+ }
Review Comment:
Can this go in a separate method?
##########
plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java:
##########
@@ -393,22 +398,76 @@ private String getRscGrp(StoragePoolVO storagePoolVO) {
storagePoolVO.getUserInfo() : "DfltRscGrp";
}
- private String createResourceBase(
- String rscName, long sizeInBytes, String volName, String vmName, DevelopersApi api, String rscGrp) {
- ResourceGroupSpawn rscGrpSpawn = new ResourceGroupSpawn();
- rscGrpSpawn.setResourceDefinitionName(rscName);
- rscGrpSpawn.addVolumeSizesItem(sizeInBytes / 1024);
-
+ /**
+ * Creates a new Linstor resource.
+ * @param rscName
+ * @param sizeInBytes
+ * @param volName
+ * @param vmName
+ * @param api
+ * @param rscGrp
+ * @param poolId
+ * @param isTemplate indicates if the resource is a template
+ * @return true if a new resource was created, false if it already existed or was reused.
+ */
+ private boolean createResourceBase(
+ String rscName, long sizeInBytes, String volName, String vmName, DevelopersApi api,
+ String rscGrp, long poolId, boolean isTemplate)
+ {
try
{
- s_logger.info("Linstor: Spawn resource " + rscName);
- ApiCallRcList answers = api.resourceGroupSpawn(rscGrp, rscGrpSpawn);
- checkLinstorAnswersThrow(answers);
-
- answers = LinstorUtil.applyAuxProps(api, rscName, volName, vmName);
- checkLinstorAnswersThrow(answers);
+ s_logger.debug(String.format("createRscBae: %s :: %s :: %b", rscName, rscGrp, isTemplate));
+ List<Pair<ResourceDefinition, ResourceGroup>> existingRDs = LinstorUtil.getRDAndRGListStartingWith(api, rscName);
+
+ String fullRscName = String.format("%s-%d", rscName, poolId);
+ boolean alreadyCreated = existingRDs.stream()
+ .anyMatch(p -> p.first().getName().equalsIgnoreCase(fullRscName)) ||
+ existingRDs.stream().anyMatch(p -> p.first().getProps().containsKey(LinstorUtil.getTemplateForAuxPropKey(rscGrp)));
+ if (!alreadyCreated) {
+ boolean createNewRsc = true;
+ if (!existingRDs.isEmpty()) {
+ ResourceGroup tgtRscGrp = api.resourceGroupList(
+ Collections.singletonList(rscGrp), null, null, null).get(0);
+ List<String> tgtLayerStack = tgtRscGrp.getSelectFilter() != null ?
+ tgtRscGrp.getSelectFilter().getLayerStack() : null;
+
+ // check if there is already a template copy, that we could reuse
+ // this means if select filters are similar enough to allow cloning from
+ for (Pair<ResourceDefinition, ResourceGroup> rdPair : existingRDs) {
+ ResourceGroup rg = rdPair.second();
+ List<String> rgLayerStack = rg.getSelectFilter() != null ?
+ rg.getSelectFilter().getLayerStack() : null;
+ if (Objects.equals(tgtLayerStack, rgLayerStack) &&
+ Objects.equals(tgtRscGrp.getSelectFilter().getStoragePoolList(),
+ rg.getSelectFilter().getStoragePoolList())) {
+ LinstorUtil.setAuxTemplateForProperty(api, rscName, rscGrp);
+ createNewRsc = false;
+ break;
+ }
+ }
+ }
- return LinstorUtil.getDevicePath(api, rscName);
+ if (createNewRsc) {
+ String newRscName = existingRDs.isEmpty() ? rscName : fullRscName;
+ ResourceGroupSpawn rscGrpSpawn = new ResourceGroupSpawn();
+ rscGrpSpawn.setResourceDefinitionName(newRscName);
+ rscGrpSpawn.addVolumeSizesItem(sizeInBytes / 1024);
+ if (isTemplate) {
+ Properties props = new Properties();
+ props.put(LinstorUtil.getTemplateForAuxPropKey(rscGrp), "true");
+ rscGrpSpawn.setResourceDefinitionProps(props);
+ }
+
+ s_logger.info("Linstor: Spawn resource " + newRscName);
+ ApiCallRcList answers = api.resourceGroupSpawn(rscGrp, rscGrpSpawn);
+ checkLinstorAnswersThrow(answers);
+
+ answers = LinstorUtil.applyAuxProps(api, newRscName, volName, vmName);
+ checkLinstorAnswersThrow(answers);
+ }
+ return createNewRsc;
+ }
+ return false;
Review Comment:
three new methods? ;)
##########
plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java:
##########
@@ -569,17 +628,29 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, KVMSt
final KVMPhysicalDisk dstDisk = destPools.createPhysicalDisk(
name, QemuImg.PhysicalDiskFormat.RAW, provisioningType, disk.getVirtualSize(), null);
+ final String rscName = getLinstorRscName(name);
final DevelopersApi api = getLinstorAPI(destPools);
- applyAuxProps(api, name, disk.getDispName(), disk.getVmName());
+ // if it is the initial systemvm disk copy, we need to apply the _cs-template-for property.
+ if (isSystemTemplate(disk)) {
+ applyAuxProps(api, name, "SystemVM Template", null);
+ LinstorStoragePool linPool = (LinstorStoragePool) destPools;
+ try {
+ LinstorUtil.setAuxTemplateForProperty(api, rscName, linPool.getResourceGroup());
+ } catch (ApiException apiExc) {
+ s_logger.error(String.format("Error setting aux template for property for %s", rscName));
+ logLinstorAnswers(apiExc.getApiCallRcList());
+ }
+ } else {
+ applyAuxProps(api, name, disk.getDispName(), disk.getVmName());
+ }
Review Comment:
new method (a good name would make the comment unnecessary.
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "rp- (via GitHub)" <gi...@apache.org>.
rp- commented on code in PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#discussion_r1931611829
##########
plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java:
##########
@@ -475,16 +486,39 @@ public boolean deletePhysicalDisk(String name, KVMStoragePool pool, Storage.Imag
{
s_logger.debug("Linstor: deletePhysicalDisk " + name);
final DevelopersApi api = getLinstorAPI(pool);
-
+ final String rscName = getLinstorRscName(name);
+ final LinstorStoragePool linstorPool = (LinstorStoragePool) pool;
+ String rscGrpName = linstorPool.getResourceGroup();
+ boolean deleted = false;
try {
- final String rscName = getLinstorRscName(name);
- s_logger.debug("Linstor: delete resource definition " + rscName);
- ApiCallRcList answers = api.resourceDefinitionDelete(rscName);
- handleLinstorApiAnswers(answers, "Linstor: Unable to delete resource definition " + rscName);
+ List<ResourceDefinition> existingRDs = LinstorUtil.getRDListStartingWith(api, rscName);
+
+ for (ResourceDefinition rd : existingRDs) {
+ int expectedProps = 0; // if it is a non template resource, we don't expect any _cs-template-for- prop
+ String propKey = LinstorUtil.getTemplateForAuxPropKey(rscGrpName);
+ if (rd.getProps().containsKey(propKey)) {
+ ResourceDefinitionModify rdm = new ResourceDefinitionModify();
+ rdm.deleteProps(Collections.singletonList(propKey));
+ api.resourceDefinitionModify(rd.getName(), rdm);
+ expectedProps = 1;
+ }
+
+ // if there is only one template-for property left for templates, the template isn't needed anymore
+ // or if it isn't a template anyway, it will not have this Aux property
+ // _cs-template-for- poperties work like a ref-count.
+ if (rd.getProps().keySet().stream()
+ .filter(key -> key.startsWith("Aux/" + LinstorUtil.CS_TEMPLATE_FOR_PREFIX))
+ .count() == expectedProps) {
+ ApiCallRcList answers = api.resourceDefinitionDelete(rd.getName());
+ checkLinstorAnswersThrow(answers);
+ deleted = true;
+ }
+ }
Review Comment:
done
##########
plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java:
##########
@@ -569,17 +628,29 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, KVMSt
final KVMPhysicalDisk dstDisk = destPools.createPhysicalDisk(
name, QemuImg.PhysicalDiskFormat.RAW, provisioningType, disk.getVirtualSize(), null);
+ final String rscName = getLinstorRscName(name);
final DevelopersApi api = getLinstorAPI(destPools);
- applyAuxProps(api, name, disk.getDispName(), disk.getVmName());
+ // if it is the initial systemvm disk copy, we need to apply the _cs-template-for property.
+ if (isSystemTemplate(disk)) {
+ applyAuxProps(api, name, "SystemVM Template", null);
+ LinstorStoragePool linPool = (LinstorStoragePool) destPools;
+ try {
+ LinstorUtil.setAuxTemplateForProperty(api, rscName, linPool.getResourceGroup());
+ } catch (ApiException apiExc) {
+ s_logger.error(String.format("Error setting aux template for property for %s", rscName));
+ logLinstorAnswers(apiExc.getApiCallRcList());
+ }
+ } else {
+ applyAuxProps(api, name, disk.getDispName(), disk.getVmName());
+ }
Review Comment:
done
##########
plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java:
##########
@@ -393,22 +398,76 @@ private String getRscGrp(StoragePoolVO storagePoolVO) {
storagePoolVO.getUserInfo() : "DfltRscGrp";
}
- private String createResourceBase(
- String rscName, long sizeInBytes, String volName, String vmName, DevelopersApi api, String rscGrp) {
- ResourceGroupSpawn rscGrpSpawn = new ResourceGroupSpawn();
- rscGrpSpawn.setResourceDefinitionName(rscName);
- rscGrpSpawn.addVolumeSizesItem(sizeInBytes / 1024);
-
+ /**
+ * Creates a new Linstor resource.
+ * @param rscName
+ * @param sizeInBytes
+ * @param volName
+ * @param vmName
+ * @param api
+ * @param rscGrp
+ * @param poolId
+ * @param isTemplate indicates if the resource is a template
+ * @return true if a new resource was created, false if it already existed or was reused.
+ */
+ private boolean createResourceBase(
+ String rscName, long sizeInBytes, String volName, String vmName, DevelopersApi api,
+ String rscGrp, long poolId, boolean isTemplate)
+ {
try
{
- s_logger.info("Linstor: Spawn resource " + rscName);
- ApiCallRcList answers = api.resourceGroupSpawn(rscGrp, rscGrpSpawn);
- checkLinstorAnswersThrow(answers);
-
- answers = LinstorUtil.applyAuxProps(api, rscName, volName, vmName);
- checkLinstorAnswersThrow(answers);
+ s_logger.debug(String.format("createRscBae: %s :: %s :: %b", rscName, rscGrp, isTemplate));
+ List<Pair<ResourceDefinition, ResourceGroup>> existingRDs = LinstorUtil.getRDAndRGListStartingWith(api, rscName);
+
+ String fullRscName = String.format("%s-%d", rscName, poolId);
+ boolean alreadyCreated = existingRDs.stream()
+ .anyMatch(p -> p.first().getName().equalsIgnoreCase(fullRscName)) ||
+ existingRDs.stream().anyMatch(p -> p.first().getProps().containsKey(LinstorUtil.getTemplateForAuxPropKey(rscGrp)));
+ if (!alreadyCreated) {
+ boolean createNewRsc = true;
+ if (!existingRDs.isEmpty()) {
+ ResourceGroup tgtRscGrp = api.resourceGroupList(
+ Collections.singletonList(rscGrp), null, null, null).get(0);
+ List<String> tgtLayerStack = tgtRscGrp.getSelectFilter() != null ?
+ tgtRscGrp.getSelectFilter().getLayerStack() : null;
+
+ // check if there is already a template copy, that we could reuse
+ // this means if select filters are similar enough to allow cloning from
+ for (Pair<ResourceDefinition, ResourceGroup> rdPair : existingRDs) {
+ ResourceGroup rg = rdPair.second();
+ List<String> rgLayerStack = rg.getSelectFilter() != null ?
+ rg.getSelectFilter().getLayerStack() : null;
+ if (Objects.equals(tgtLayerStack, rgLayerStack) &&
+ Objects.equals(tgtRscGrp.getSelectFilter().getStoragePoolList(),
+ rg.getSelectFilter().getStoragePoolList())) {
+ LinstorUtil.setAuxTemplateForProperty(api, rscName, rscGrp);
+ createNewRsc = false;
+ break;
+ }
+ }
+ }
- return LinstorUtil.getDevicePath(api, rscName);
+ if (createNewRsc) {
+ String newRscName = existingRDs.isEmpty() ? rscName : fullRscName;
+ ResourceGroupSpawn rscGrpSpawn = new ResourceGroupSpawn();
+ rscGrpSpawn.setResourceDefinitionName(newRscName);
+ rscGrpSpawn.addVolumeSizesItem(sizeInBytes / 1024);
+ if (isTemplate) {
+ Properties props = new Properties();
+ props.put(LinstorUtil.getTemplateForAuxPropKey(rscGrp), "true");
+ rscGrpSpawn.setResourceDefinitionProps(props);
+ }
+
+ s_logger.info("Linstor: Spawn resource " + newRscName);
+ ApiCallRcList answers = api.resourceGroupSpawn(rscGrp, rscGrpSpawn);
+ checkLinstorAnswersThrow(answers);
+
+ answers = LinstorUtil.applyAuxProps(api, newRscName, volName, vmName);
+ checkLinstorAnswersThrow(answers);
+ }
+ return createNewRsc;
+ }
+ return false;
Review Comment:
done
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2620166116
<b>[SF] Trillian test result (tid-12206)</b>
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 46137 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10280-t12206-kvm-ol8.zip
Smoke tests completed. 133 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland merged PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2615677994
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/10280?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 4.29%. Comparing base [(`b186272`)](https://app.codecov.io/gh/apache/cloudstack/commit/b186272f6878edcfd7145a3b9a9d0c61311ad94b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`1ff6d37`)](https://app.codecov.io/gh/apache/cloudstack/commit/1ff6d3745ccd7d92213fc07ce829022be02526bc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 8 commits behind head on 4.19.
> :exclamation: There is a different number of reports uploaded between BASE (b186272) and HEAD (1ff6d37). Click for more details.
>
> <details><summary>HEAD has 1 upload less than BASE</summary>
>
>| Flag | BASE (b186272) | HEAD (1ff6d37) |
>|------|------|------|
>|unittests|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 4.19 #10280 +/- ##
=============================================
- Coverage 15.13% 4.29% -10.84%
=============================================
Files 5408 366 -5042
Lines 474014 29589 -444425
Branches 57824 5186 -52638
=============================================
- Hits 71750 1272 -70478
+ Misses 394241 28172 -366069
+ Partials 8023 145 -7878
```
| [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/10280/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/10280/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.29% <ø> (-0.01%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/10280/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.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/10280?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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2638889785
<b>[SF] Trillian test result (tid-12320)</b>
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 50641 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10280-t12320-kvm-ol8.zip
Smoke tests completed. 132 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
test_12_start_vm_multiple_volumes_allocated | `Error` | 15.25 | 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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "rp- (via GitHub)" <gi...@apache.org>.
rp- commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2636525248
@DaanHoogland sorry took a while had to retest, encryption and this change here.
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2636791830
> @DaanHoogland sorry took a while had to retest, encryption and this change here.
ok, I'll do one more round
--
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] linstor: Fix using multiple primary storage with same linstor-controller [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10280:
URL: https://github.com/apache/cloudstack/pull/10280#issuecomment-2636792298
@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