Skip to content

Commit b7be64f

Browse files
committed
fix(linstor): use name filter in isResourceDefinitionGone
resourceDefinitionList(null, ...) fetched every RD on the cluster and then streamed for a match — repeated once per second from waitForResourceDefinitionDeleted this scales with cluster size. Pass the name as the rscDfns filter so the controller returns an empty list when the RD is gone. Also clarify the timeout-constant Javadoc per copilot/abh1sar review (constant is used from management-server paths too, not just agents). Addresses review comments from @rp- and Copilot on #13076.
1 parent 21c6110 commit b7be64f

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

  • plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/util

plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/util/LinstorUtil.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,22 +404,23 @@ public static List<ResourceDefinition> getRDListStartingWith(DevelopersApi api,
404404
/**
405405
* Default per-call timeout for {@link #waitForResourceDefinitionDeleted}. Long enough for a
406406
* healthy LINSTOR controller to finish a normal delete; short enough not to block the calling
407-
* agent thread for too long if the delete is genuinely stuck.
407+
* thread for too long if the delete is genuinely stuck. Used both from the management server
408+
* (e.g. {@code LinstorPrimaryDataStoreDriverImpl}) and from KVM agent paths.
408409
*/
409410
public static final long DEFAULT_RD_DELETE_VERIFY_TIMEOUT_MILLIS = 30_000L;
410411

411412
/**
412413
* Returns {@code true} if the named resource definition is no longer present on the LINSTOR
413414
* controller. Used after a {@code resourceDefinitionDelete} to verify the delete actually
414415
* completed (LINSTOR can return success on the API call while the resource lingers in
415-
* DELETING state due to peer issues, lost quorum, or down satellites).
416+
* DELETING state due to peer issues, lost quorum, or down satellites). Uses the
417+
* controller-side name filter rather than scanning every RD on the cluster (cheap even
418+
* when polled once per second from {@link #waitForResourceDefinitionDeleted}).
416419
*/
417420
public static boolean isResourceDefinitionGone(DevelopersApi api, String rscName) throws ApiException {
418-
List<ResourceDefinition> all = api.resourceDefinitionList(null, false, null, null, null);
419-
if (all == null) {
420-
return true;
421-
}
422-
return all.stream().noneMatch(rd -> rscName.equalsIgnoreCase(rd.getName()));
421+
List<ResourceDefinition> matching =
422+
api.resourceDefinitionList(Collections.singletonList(rscName), false, null, null, null);
423+
return matching == null || matching.isEmpty();
423424
}
424425

425426
/**

0 commit comments

Comments
 (0)