Storage plugin support to check if volume on datastore requires access for migration (#8655)

* Check if volume on datastore requires access for migration, and grant/revoke volume access if requires

* Updated default implementation for requiresAccessForMigration method in PrimaryDataStoreDriver
This commit is contained in:
Suresh Kumar Anaparti 2024-02-26 20:16:31 +05:30 committed by GitHub
parent 18c3d470c6
commit f731fe882c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 28 additions and 4 deletions

View File

@ -42,6 +42,10 @@ public interface PrimaryDataStoreDriver extends DataStoreDriver {
void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);
default boolean requiresAccessForMigration(DataObject dataObject) {
return false;
}
/**
* intended for managed storage (cloud.storage_pool.managed = true)
* if not managed, return volume.getSize()

View File

@ -54,6 +54,8 @@ public interface VolumeService {
void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);
boolean requiresAccessForMigration(DataObject dataObject, DataStore dataStore);
/**
* Creates the volume based on the given criteria
*

View File

@ -1228,8 +1228,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
DataStore dataStore = dataStoreMgr.getDataStore(volumeForVm.getPoolId(), DataStoreRole.Primary);
PrimaryDataStore primaryDataStore = (PrimaryDataStore)dataStore;
// This might impact other managed storages, grant access for PowerFlex storage pool only
if (primaryDataStore.isManaged() && primaryDataStore.getPoolType() == Storage.StoragePoolType.PowerFlex) {
// This might impact other managed storages, enable requires access for migration in relevant datastore driver (currently enabled for PowerFlex storage pool only)
if (primaryDataStore.isManaged() && volService.requiresAccessForMigration(volumeInfo, dataStore)) {
volService.revokeAccess(volumeInfo, host, dataStore);
}
}
@ -1507,8 +1507,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
disk.setDetails(getDetails(volumeInfo, dataStore));
PrimaryDataStore primaryDataStore = (PrimaryDataStore)dataStore;
// This might impact other managed storages, grant access for PowerFlex storage pool only
if (primaryDataStore.isManaged() && primaryDataStore.getPoolType() == Storage.StoragePoolType.PowerFlex) {
// This might impact other managed storages, enable requires access for migration in relevant datastore driver (currently enabled for PowerFlex storage pool only)
if (primaryDataStore.isManaged() && volService.requiresAccessForMigration(volumeInfo, dataStore)) {
volService.grantAccess(volFactory.getVolume(vol.getId()), dest.getHost(), dataStore);
}

View File

@ -266,6 +266,19 @@ public class VolumeServiceImpl implements VolumeService {
}
}
@Override
public boolean requiresAccessForMigration(DataObject dataObject, DataStore dataStore) {
DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
if (dataStoreDriver == null) {
return false;
}
if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
return ((PrimaryDataStoreDriver)dataStoreDriver).requiresAccessForMigration(dataObject);
}
return false;
}
@Override
public AsyncCallFuture<VolumeApiResult> createVolumeAsync(VolumeInfo volume, DataStore dataStore) {
AsyncCallFuture<VolumeApiResult> future = new AsyncCallFuture<VolumeApiResult>();

View File

@ -302,6 +302,11 @@ public class ScaleIOPrimaryDataStoreDriver implements PrimaryDataStoreDriver {
return null;
}
@Override
public boolean requiresAccessForMigration(DataObject dataObject) {
return true;
}
@Override
public long getUsedBytes(StoragePool storagePool) {
long usedSpaceBytes = 0;