rp- commented on code in PR #13078:
URL: https://github.com/apache/cloudstack/pull/13078#discussion_r3189132162
##########
plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java:
##########
@@ -508,9 +508,20 @@ private boolean deRefOrDeleteResource(DevelopersApi api,
String rscName, String
// 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- properties work like a ref-count.
- if (rd.getProps().keySet().stream()
+ long remainingTemplateRefs = rd.getProps().keySet().stream()
.filter(key -> key.startsWith("Aux/" +
LinstorUtil.CS_TEMPLATE_FOR_PREFIX))
- .count() == expectedProps) {
+ .count();
+ if (remainingTemplateRefs == expectedProps) {
+ // Surface the case where a resource that LOOKS like a
template (resource name
+ // starts with the requested prefix) has zero
`_cs-template-for-` aux properties
+ // even though we never decremented one — that's a legacy
template predating the
+ // ref-count convention. Logging it before deletion lets
operators audit how
+ // many such orphans existed at upgrade time.
+ if (expectedProps == 0 &&
rd.getName().toLowerCase().startsWith(rscName.toLowerCase())) {
+ logger.info("Linstor: deleting resource {} which has no
_cs-template-for- aux properties " +
+ "(legacy template predating the ref-count
convention, or a stale orphan). " +
+ "Resource group context: {}",
rd.getName(), rscGrpName);
+ }
Review Comment:
copilot has a point here. the extra .startWith, will always be true, as the
existingRD will exactly only contain resources only such resources.
--
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]