mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-18 19:44:21 +01:00
Introduced new global setting volume.check.and.repair.before.use to do volume check and repair before VM start or volume attach operations
This commit is contained in:
parent
2710405e81
commit
94e7051c6e
@ -1915,6 +1915,15 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// For unmanaged storage this is not a mandatory step but this is kept here so that volume can be checked and repaired if needed based on the
|
||||||
|
// global setting volume.check.and.repair.before.use
|
||||||
|
Host host = _hostDao.findById(vm.getVirtualMachine().getHostId());
|
||||||
|
try {
|
||||||
|
volService.grantAccess(volFactory.getVolume(vol.getId()), host, (DataStore)pool);
|
||||||
|
} catch (Exception e) {
|
||||||
|
s_logger.debug(String.format("Unable to grant access to volume [%s] on host [%s], due to %s.", volToString, host, e.getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (task.type == VolumeTaskType.MIGRATE) {
|
} else if (task.type == VolumeTaskType.MIGRATE) {
|
||||||
pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
|
pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
|
||||||
|
|||||||
@ -251,18 +251,20 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
|
DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
|
||||||
|
|
||||||
if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
|
if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
|
||||||
return ((PrimaryDataStoreDriver)dataStoreDriver).grantAccess(dataObject, host, dataStore);
|
boolean result = ((PrimaryDataStoreDriver)dataStoreDriver).grantAccess(dataObject, host, dataStore);
|
||||||
}
|
|
||||||
|
|
||||||
if (com.cloud.storage.VolumeApiServiceImpl.AllowVolumeCheckAndRepair.value()) {
|
|
||||||
if (HypervisorType.KVM.equals(host.getHypervisorType()) && DataObjectType.VOLUME.equals(dataObject.getType())) {
|
if (HypervisorType.KVM.equals(host.getHypervisorType()) && DataObjectType.VOLUME.equals(dataObject.getType())) {
|
||||||
s_logger.info(String.format("Trying to check and repair the volume %d", dataObject.getId()));
|
if (com.cloud.storage.VolumeApiServiceImpl.AllowVolumeCheckAndRepair.value()) {
|
||||||
String repair = CheckVolumeAndRepairCmd.RepairValues.leaks.name();
|
s_logger.info(String.format("Trying to check and repair the volume %d", dataObject.getId()));
|
||||||
CheckAndRepairVolumePayload payload = new CheckAndRepairVolumePayload(repair);
|
String repair = CheckVolumeAndRepairCmd.RepairValues.leaks.name();
|
||||||
VolumeInfo volumeInfo = volFactory.getVolume(dataObject.getId());
|
CheckAndRepairVolumePayload payload = new CheckAndRepairVolumePayload(repair);
|
||||||
volumeInfo.addPayload(payload);
|
VolumeInfo volumeInfo = volFactory.getVolume(dataObject.getId());
|
||||||
checkAndRepairVolume(volumeInfo);
|
volumeInfo.addPayload(payload);
|
||||||
|
checkAndRepairVolume(volumeInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -381,8 +381,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||||||
public static ConfigKey<Long> storageTagRuleExecutionTimeout = new ConfigKey<>("Advanced", Long.class, "storage.tag.rule.execution.timeout", "2000", "The maximum runtime,"
|
public static ConfigKey<Long> storageTagRuleExecutionTimeout = new ConfigKey<>("Advanced", Long.class, "storage.tag.rule.execution.timeout", "2000", "The maximum runtime,"
|
||||||
+ " in milliseconds, to execute a storage tag rule; if it is reached, a timeout will happen.", true);
|
+ " in milliseconds, to execute a storage tag rule; if it is reached, a timeout will happen.", true);
|
||||||
|
|
||||||
public static final ConfigKey<Boolean> AllowVolumeCheckAndRepair = new ConfigKey<Boolean>("Hidden", Boolean.class, "volume.check.and.repair.before.instance.use", "true",
|
public static final ConfigKey<Boolean> AllowVolumeCheckAndRepair = new ConfigKey<Boolean>("Advanced", Boolean.class, "volume.check.and.repair.before.use", "false",
|
||||||
"To check and repair the volume if it has any leaks before performing any volume operation", true);
|
"To check and repair the volume if it has any leaks before performing volume attach or VM start operations", true);
|
||||||
|
|
||||||
private final StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;
|
private final StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user