Skip to content
This repository was archived by the owner on Jan 4, 2022. It is now read-only.

Commit 0097fa2

Browse files
Daishan PengCraig Jellick
authored andcommitted
add lock even when volume is active and detached
we should also add lock in scheduling instances when volume is active but detached. This will prevent a race condition when we try to schedule instances using an existing volume or when it failed to pass healthcheck and reschedule containers using existing volume.
1 parent 6ca29b2 commit 0097fa2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

code/iaas/allocator/src/main/java/io/cattle/platform/allocator/service/impl/AllocatorServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ protected LockDefinition getInstanceLockDef(Instance origInstance, List<Instance
368368
if (driver != null) {
369369
String accessMode = DataAccessor.fieldString(driver, StorageDriverConstants.FIELD_VOLUME_ACCESS_MODE);
370370
if (VolumeConstants.ACCESS_MODE_SINGLE_HOST_RW.equals(accessMode) || VolumeConstants.ACCESS_MODE_SINGLE_INSTANCE_RW.equals(accessMode)) {
371-
if (!CommonStatesConstants.ACTIVE.equals(volume.getAllocationState())) {
371+
if (!CommonStatesConstants.ACTIVE.equals(volume.getAllocationState()) || VolumeConstants.STATE_DETACHED.equals(volume.getState())) {
372372
locks.add(new AllocateConstraintLock(AllocateConstraintLock.Type.VOLUME, volume.getId().toString()));
373373
}
374374
}

0 commit comments

Comments
 (0)