mirror of https://github.com/apache/cloudstack.git
Added volume check and repair changes only during VM start and volume attach operations
This commit is contained in:
parent
94e7051c6e
commit
e08aac037b
|
|
@ -117,4 +117,6 @@ public interface VolumeService {
|
|||
void moveVolumeOnSecondaryStorageToAnotherAccount(Volume volume, Account sourceAccount, Account destAccount);
|
||||
|
||||
Pair<String, String> checkAndRepairVolume(VolumeInfo volume);
|
||||
|
||||
void checkAndRepairVolumeBasedOnConfig(DataObject dataObject, Host host);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1916,13 +1916,11 @@ 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);
|
||||
volService.checkAndRepairVolumeBasedOnConfig(volFactory.getVolume(vol.getId()), host);
|
||||
} 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()));
|
||||
s_logger.debug(String.format("Unable to check and repair volume [%s] on host [%s], due to %s.", volToString, host, e.getMessage()));
|
||||
}
|
||||
}
|
||||
} else if (task.type == VolumeTaskType.MIGRATE) {
|
||||
|
|
|
|||
|
|
@ -251,20 +251,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null;
|
||||
|
||||
if (dataStoreDriver instanceof PrimaryDataStoreDriver) {
|
||||
boolean result = ((PrimaryDataStoreDriver)dataStoreDriver).grantAccess(dataObject, host, dataStore);
|
||||
|
||||
if (HypervisorType.KVM.equals(host.getHypervisorType()) && DataObjectType.VOLUME.equals(dataObject.getType())) {
|
||||
if (com.cloud.storage.VolumeApiServiceImpl.AllowVolumeCheckAndRepair.value()) {
|
||||
s_logger.info(String.format("Trying to check and repair the volume %d", dataObject.getId()));
|
||||
String repair = CheckVolumeAndRepairCmd.RepairValues.leaks.name();
|
||||
CheckAndRepairVolumePayload payload = new CheckAndRepairVolumePayload(repair);
|
||||
VolumeInfo volumeInfo = volFactory.getVolume(dataObject.getId());
|
||||
volumeInfo.addPayload(payload);
|
||||
checkAndRepairVolume(volumeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return ((PrimaryDataStoreDriver)dataStoreDriver).grantAccess(dataObject, host, dataStore);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -2778,6 +2765,20 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
return snapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkAndRepairVolumeBasedOnConfig(DataObject dataObject, Host host) {
|
||||
if (HypervisorType.KVM.equals(host.getHypervisorType()) && DataObjectType.VOLUME.equals(dataObject.getType())) {
|
||||
if (com.cloud.storage.VolumeApiServiceImpl.AllowVolumeCheckAndRepair.value()) {
|
||||
s_logger.info(String.format("Trying to check and repair the volume %d", dataObject.getId()));
|
||||
String repair = CheckVolumeAndRepairCmd.RepairValues.leaks.name();
|
||||
CheckAndRepairVolumePayload payload = new CheckAndRepairVolumePayload(repair);
|
||||
VolumeInfo volumeInfo = volFactory.getVolume(dataObject.getId());
|
||||
volumeInfo.addPayload(payload);
|
||||
checkAndRepairVolume(volumeInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<String, String> checkAndRepairVolume(VolumeInfo volume) {
|
||||
Long poolId = volume.getPoolId();
|
||||
|
|
|
|||
|
|
@ -4396,6 +4396,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
try {
|
||||
// if we don't have a host, the VM we are attaching the disk to has never been started before
|
||||
if (host != null) {
|
||||
try {
|
||||
volService.checkAndRepairVolumeBasedOnConfig(volFactory.getVolume(volumeToAttach.getId()), host);
|
||||
} catch (Exception e) {
|
||||
s_logger.debug(String.format("Unable to check and repair volume [%s] on host [%s], due to %s.", volumeToAttach.getName(), host, e.getMessage()));
|
||||
}
|
||||
|
||||
try {
|
||||
volService.grantAccess(volFactory.getVolume(volumeToAttach.getId()), host, dataStore);
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue