mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Snapshot removal and storage cleanup logs (#8031)
This commit is contained in:
parent
314537a8df
commit
e437d1016f
@ -364,7 +364,7 @@ public class SnapshotServiceImpl implements SnapshotService {
|
|||||||
SnapshotResult res = null;
|
SnapshotResult res = null;
|
||||||
try {
|
try {
|
||||||
if (result.isFailed()) {
|
if (result.isFailed()) {
|
||||||
s_logger.debug("delete snapshot failed" + result.getResult());
|
s_logger.debug(String.format("Failed to delete snapshot [%s] due to: [%s].", snapshot.getUuid(), result.getResult()));
|
||||||
snapshot.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed);
|
snapshot.processEvent(ObjectInDataStoreStateMachine.Event.OperationFailed);
|
||||||
res = new SnapshotResult(context.snapshot, null);
|
res = new SnapshotResult(context.snapshot, null);
|
||||||
res.setResult(result.getResult());
|
res.setResult(result.getResult());
|
||||||
@ -373,7 +373,8 @@ public class SnapshotServiceImpl implements SnapshotService {
|
|||||||
res = new SnapshotResult(context.snapshot, null);
|
res = new SnapshotResult(context.snapshot, null);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.debug("Failed to in deleteSnapshotCallback", e);
|
s_logger.error(String.format("An exception occurred while processing an event in delete snapshot callback from snapshot [%s].", snapshot.getUuid()));
|
||||||
|
s_logger.debug(String.format("Exception while processing an event in delete snapshot callback from snapshot [%s].", snapshot.getUuid()), e);
|
||||||
res.setResult(e.toString());
|
res.setResult(e.toString());
|
||||||
}
|
}
|
||||||
future.complete(res);
|
future.complete(res);
|
||||||
@ -418,15 +419,14 @@ public class SnapshotServiceImpl implements SnapshotService {
|
|||||||
if (result.isFailed()) {
|
if (result.isFailed()) {
|
||||||
throw new CloudRuntimeException(result.getResult());
|
throw new CloudRuntimeException(result.getResult());
|
||||||
}
|
}
|
||||||
|
s_logger.debug(String.format("Successfully deleted snapshot [%s] with ID [%s].", snapInfo.getName(), snapInfo.getUuid()));
|
||||||
return true;
|
return true;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
s_logger.debug("delete snapshot is failed: " + e.toString());
|
s_logger.error(String.format("Failed to delete snapshot [%s] due to: [%s].", snapInfo.getUuid(), e.getMessage()));
|
||||||
} catch (ExecutionException e) {
|
s_logger.debug(String.format("Failed to delete snapshot [%s].", snapInfo.getUuid()), e);
|
||||||
s_logger.debug("delete snapshot is failed: " + e.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -1289,26 +1289,27 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
List<VMTemplateStoragePoolVO> unusedTemplatesInPool = _tmpltMgr.getUnusedTemplatesInPool(pool);
|
List<VMTemplateStoragePoolVO> unusedTemplatesInPool = _tmpltMgr.getUnusedTemplatesInPool(pool);
|
||||||
s_logger.debug("Storage pool garbage collector found " + unusedTemplatesInPool.size() + " templates to clean up in storage pool: " + pool.getName());
|
s_logger.debug(String.format("Storage pool garbage collector found [%s] templates to be cleaned up in storage pool [%s].", unusedTemplatesInPool.size(), pool.getName()));
|
||||||
for (VMTemplateStoragePoolVO templatePoolVO : unusedTemplatesInPool) {
|
for (VMTemplateStoragePoolVO templatePoolVO : unusedTemplatesInPool) {
|
||||||
if (templatePoolVO.getDownloadState() != VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
|
if (templatePoolVO.getDownloadState() != VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
|
||||||
s_logger.debug("Storage pool garbage collector is skipping template with ID: " + templatePoolVO.getTemplateId() + " on pool " + templatePoolVO.getPoolId()
|
s_logger.debug(String.format("Storage pool garbage collector is skipping template [%s] clean up on pool [%s] " +
|
||||||
+ " because it is not completely downloaded.");
|
"because it is not completely downloaded.", templatePoolVO.getTemplateId(), templatePoolVO.getPoolId()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!templatePoolVO.getMarkedForGC()) {
|
if (!templatePoolVO.getMarkedForGC()) {
|
||||||
templatePoolVO.setMarkedForGC(true);
|
templatePoolVO.setMarkedForGC(true);
|
||||||
_vmTemplatePoolDao.update(templatePoolVO.getId(), templatePoolVO);
|
_vmTemplatePoolDao.update(templatePoolVO.getId(), templatePoolVO);
|
||||||
s_logger.debug("Storage pool garbage collector has marked template with ID: " + templatePoolVO.getTemplateId() + " on pool " + templatePoolVO.getPoolId()
|
s_logger.debug(String.format("Storage pool garbage collector has marked template [%s] on pool [%s] " +
|
||||||
+ " for garbage collection.");
|
"for garbage collection.", templatePoolVO.getTemplateId(), templatePoolVO.getPoolId()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_tmpltMgr.evictTemplateFromStoragePool(templatePoolVO);
|
_tmpltMgr.evictTemplateFromStoragePool(templatePoolVO);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Problem cleaning up primary storage pool " + pool, e);
|
s_logger.error(String.format("Failed to clean up primary storage pool [%s] due to: [%s].", pool, e.getMessage()));
|
||||||
|
s_logger.debug(String.format("Failed to clean up primary storage pool [%s].", pool), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1316,10 +1317,39 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
//destroy snapshots in destroying state in snapshot_store_ref
|
//destroy snapshots in destroying state in snapshot_store_ref
|
||||||
List<SnapshotDataStoreVO> ssSnapshots = _snapshotStoreDao.listByState(ObjectInDataStoreStateMachine.State.Destroying);
|
List<SnapshotDataStoreVO> ssSnapshots = _snapshotStoreDao.listByState(ObjectInDataStoreStateMachine.State.Destroying);
|
||||||
for (SnapshotDataStoreVO ssSnapshotVO : ssSnapshots) {
|
for (SnapshotDataStoreVO ssSnapshotVO : ssSnapshots) {
|
||||||
|
String snapshotUuid = null;
|
||||||
|
SnapshotVO snapshot = null;
|
||||||
|
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
snapshot = _snapshotDao.findById(ssSnapshotVO.getSnapshotId());
|
||||||
|
if (snapshot == null) {
|
||||||
|
s_logger.warn(String.format("Did not find snapshot [%s] in destroying state; therefore, it cannot be destroyed.", ssSnapshotVO.getSnapshotId()));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshotUuid = snapshot.getUuid();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_snapshotService.deleteSnapshot(snapshotFactory.getSnapshot(ssSnapshotVO.getSnapshotId(), DataStoreRole.Image));
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug(String.format("Verifying if snapshot [%s] is in destroying state in any image data store.", snapshotUuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
SnapshotInfo snapshotInfo = snapshotFactory.getSnapshot(ssSnapshotVO.getSnapshotId(), DataStoreRole.Image);
|
||||||
|
|
||||||
|
if (snapshotInfo != null) {
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug(String.format("Snapshot [%s] in destroying state found in image data store [%s]; therefore, it will be destroyed.", snapshotUuid, snapshotInfo.getDataStore().getUuid()));
|
||||||
|
}
|
||||||
|
_snapshotService.deleteSnapshot(snapshotInfo);
|
||||||
|
} else if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug(String.format("Did not find snapshot [%s] in destroying state in any image data store.", snapshotUuid));
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.debug("Failed to delete snapshot: " + ssSnapshotVO.getId() + " from storage");
|
s_logger.error(String.format("Failed to delete snapshot [%s] from storage due to: [%s].", ssSnapshotVO.getSnapshotId(), e.getMessage()));
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug(String.format("Failed to delete snapshot [%s] from storage.", snapshotUuid), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cleanupSecondaryStorage(recurring);
|
cleanupSecondaryStorage(recurring);
|
||||||
@ -1343,7 +1373,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
// system, but not necessary.
|
// system, but not necessary.
|
||||||
handleManagedStorage(vol);
|
handleManagedStorage(vol);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Unable to destroy host-side clustered file system " + vol.getUuid(), e);
|
s_logger.error(String.format("Unable to destroy host-side clustered file system [%s] due to: [%s].", vol.getUuid(), e.getMessage()));
|
||||||
|
s_logger.debug(String.format("Unable to destroy host-side clustered file system [%s].", vol.getUuid()), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1352,10 +1383,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
volService.ensureVolumeIsExpungeReady(vol.getId());
|
volService.ensureVolumeIsExpungeReady(vol.getId());
|
||||||
volService.expungeVolumeAsync(volumeInfo);
|
volService.expungeVolumeAsync(volumeInfo);
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("Volume " + vol.getUuid() + " is already destroyed");
|
s_logger.debug(String.format("Volume [%s] is already destroyed.", vol.getUuid()));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Unable to destroy volume " + vol.getUuid(), e);
|
s_logger.error(String.format("Unable to destroy volume [%s] due to: [%s].", vol.getUuid(), e.getMessage()));
|
||||||
|
s_logger.debug(String.format("Unable to destroy volume [%s].", vol.getUuid()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1369,7 +1401,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
}
|
}
|
||||||
_snapshotDao.expunge(snapshotVO.getId());
|
_snapshotDao.expunge(snapshotVO.getId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Unable to destroy snapshot " + snapshotVO.getUuid(), e);
|
s_logger.error(String.format("Unable to destroy snapshot [%s] due to: [%s].", snapshotVO.getUuid(), e.getMessage()));
|
||||||
|
s_logger.debug(String.format("Unable to destroy snapshot [%s].", snapshotVO.getUuid()), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1378,14 +1411,14 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
for (VolumeDataStoreVO volumeDataStore : volumeDataStores) {
|
for (VolumeDataStoreVO volumeDataStore : volumeDataStores) {
|
||||||
VolumeVO volume = volumeDao.findById(volumeDataStore.getVolumeId());
|
VolumeVO volume = volumeDao.findById(volumeDataStore.getVolumeId());
|
||||||
if (volume == null) {
|
if (volume == null) {
|
||||||
s_logger.warn("Uploaded volume with id " + volumeDataStore.getVolumeId() + " not found, so cannot be destroyed");
|
s_logger.warn(String.format("Uploaded volume [%s] not found, so cannot be destroyed.", volumeDataStore.getVolumeId()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DataStore dataStore = _dataStoreMgr.getDataStore(volumeDataStore.getDataStoreId(), DataStoreRole.Image);
|
DataStore dataStore = _dataStoreMgr.getDataStore(volumeDataStore.getDataStoreId(), DataStoreRole.Image);
|
||||||
EndPoint ep = _epSelector.select(dataStore, volumeDataStore.getExtractUrl());
|
EndPoint ep = _epSelector.select(dataStore, volumeDataStore.getExtractUrl());
|
||||||
if (ep == null) {
|
if (ep == null) {
|
||||||
s_logger.warn("There is no secondary storage VM for image store " + dataStore.getName() + ", cannot destroy uploaded volume " + volume.getUuid());
|
s_logger.warn(String.format("There is no secondary storage VM for image store [%s], cannot destroy uploaded volume [%s].", dataStore.getName(), volume.getUuid()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Host host = _hostDao.findById(ep.getId());
|
Host host = _hostDao.findById(ep.getId());
|
||||||
@ -1397,17 +1430,18 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
// expunge volume from secondary if volume is on image store
|
// expunge volume from secondary if volume is on image store
|
||||||
VolumeInfo volOnSecondary = volFactory.getVolume(volume.getId(), DataStoreRole.Image);
|
VolumeInfo volOnSecondary = volFactory.getVolume(volume.getId(), DataStoreRole.Image);
|
||||||
if (volOnSecondary != null) {
|
if (volOnSecondary != null) {
|
||||||
s_logger.info("Expunging volume " + volume.getUuid() + " uploaded using HTTP POST from secondary data store");
|
s_logger.info(String.format("Expunging volume [%s] uploaded using HTTP POST from secondary data store.", volume.getUuid()));
|
||||||
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volOnSecondary);
|
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volOnSecondary);
|
||||||
VolumeApiResult result = future.get();
|
VolumeApiResult result = future.get();
|
||||||
if (!result.isSuccess()) {
|
if (!result.isSuccess()) {
|
||||||
s_logger.warn("Failed to expunge volume " + volume.getUuid() + " from the image store " + dataStore.getName() + " due to: " + result.getResult());
|
s_logger.warn(String.format("Failed to expunge volume [%s] from the image store [%s] due to: [%s].", volume.getUuid(), dataStore.getName(), result.getResult()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
s_logger.warn("Unable to destroy uploaded volume " + volume.getUuid() + ". Error details: " + th.getMessage());
|
s_logger.error(String.format("Unable to destroy uploaded volume [%s] due to: [%s].", volume.getUuid(), th.getMessage()));
|
||||||
|
s_logger.debug(String.format("Unable to destroy uploaded volume [%s].", volume.getUuid()), th);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1416,14 +1450,14 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
for (TemplateDataStoreVO templateDataStore : templateDataStores) {
|
for (TemplateDataStoreVO templateDataStore : templateDataStores) {
|
||||||
VMTemplateVO template = _templateDao.findById(templateDataStore.getTemplateId());
|
VMTemplateVO template = _templateDao.findById(templateDataStore.getTemplateId());
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
s_logger.warn("Uploaded template with id " + templateDataStore.getTemplateId() + " not found, so cannot be destroyed");
|
s_logger.warn(String.format("Uploaded template [%s] not found, so cannot be destroyed.", templateDataStore.getTemplateId()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DataStore dataStore = _dataStoreMgr.getDataStore(templateDataStore.getDataStoreId(), DataStoreRole.Image);
|
DataStore dataStore = _dataStoreMgr.getDataStore(templateDataStore.getDataStoreId(), DataStoreRole.Image);
|
||||||
EndPoint ep = _epSelector.select(dataStore, templateDataStore.getExtractUrl());
|
EndPoint ep = _epSelector.select(dataStore, templateDataStore.getExtractUrl());
|
||||||
if (ep == null) {
|
if (ep == null) {
|
||||||
s_logger.warn("There is no secondary storage VM for image store " + dataStore.getName() + ", cannot destroy uploaded template " + template.getUuid());
|
s_logger.warn(String.format("Cannot destroy uploaded template [%s] as there is no secondary storage VM for image store [%s].", template.getUuid(), dataStore.getName()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Host host = _hostDao.findById(ep.getId());
|
Host host = _hostDao.findById(ep.getId());
|
||||||
@ -1432,7 +1466,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
AsyncCallFuture<TemplateApiResult> future = _imageSrv.deleteTemplateAsync(tmplFactory.getTemplate(template.getId(), dataStore));
|
AsyncCallFuture<TemplateApiResult> future = _imageSrv.deleteTemplateAsync(tmplFactory.getTemplate(template.getId(), dataStore));
|
||||||
TemplateApiResult result = future.get();
|
TemplateApiResult result = future.get();
|
||||||
if (!result.isSuccess()) {
|
if (!result.isSuccess()) {
|
||||||
s_logger.warn("Failed to delete template " + template.getUuid() + " from the image store " + dataStore.getName() + " due to: " + result.getResult());
|
s_logger.warn(String.format("Failed to delete template [%s] from image store [%s] due to: [%s]", template.getUuid(), dataStore.getName(), result.getResult()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// remove from template_zone_ref
|
// remove from template_zone_ref
|
||||||
@ -1456,7 +1490,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
s_logger.warn("Unable to destroy uploaded template " + template.getUuid() + ". Error details: " + th.getMessage());
|
s_logger.error(String.format("Unable to destroy uploaded template [%s] due to: [%s].", template.getUuid(), th.getMessage()));
|
||||||
|
s_logger.debug(String.format("Unable to destroy uploaded template [%s].", template.getUuid()), th);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cleanupInactiveTemplates();
|
cleanupInactiveTemplates();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user