Skip to content

Commit eff9b09

Browse files
committed
fix(linstor): drop redundant startsWith check in deRefOrDeleteResource
existingRDs already filtered by getRDListStartingWith(rscName), so the .startsWith() guard is always true. Per @rp- review on PR #13078.
1 parent 70eed01 commit eff9b09

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -512,12 +512,11 @@ private boolean deRefOrDeleteResource(DevelopersApi api, String rscName, String
512512
.filter(key -> key.startsWith("Aux/" + LinstorUtil.CS_TEMPLATE_FOR_PREFIX))
513513
.count();
514514
if (remainingTemplateRefs == expectedProps) {
515-
// Surface the case where a resource that LOOKS like a template (resource name
516-
// starts with the requested prefix) has zero `_cs-template-for-` aux properties
517-
// even though we never decremented one — that's a legacy template predating the
518-
// ref-count convention. Logging it before deletion lets operators audit how
519-
// many such orphans existed at upgrade time.
520-
if (expectedProps == 0 && rd.getName().toLowerCase().startsWith(rscName.toLowerCase())) {
515+
// Surface the legacy case where a resource has zero `_cs-template-for-` aux
516+
// properties even though we never decremented one — that's a template predating
517+
// the ref-count convention, or a stale orphan. Logging before deletion lets
518+
// operators audit how many such orphans existed at upgrade time.
519+
if (expectedProps == 0) {
521520
logger.info("Linstor: deleting resource {} which has no _cs-template-for- aux properties " +
522521
"(legacy template predating the ref-count convention, or a stale orphan). " +
523522
"Resource group context: {}", rd.getName(), rscGrpName);

0 commit comments

Comments
 (0)