mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Seperate template cleanup control to enable template preloading
This commit is contained in:
parent
8249c072ee
commit
fe9ccf33b5
@ -55,6 +55,7 @@ public enum Config {
|
||||
MaxVolumeSize("Storage", ManagementServer.class, Integer.class, "storage.max.volume.size", "2000", "The maximum size for a volume (in GB).", null),
|
||||
TotalRetries("Storage", AgentManager.class, Integer.class, "total.retries", "4", "The number of times each command sent to a host should be retried in case of failure.", null),
|
||||
StoragePoolMaxWaitSeconds("Storage", ManagementServer.class, Integer.class, "storage.pool.max.waitseconds", "3600", "Timeout (in seconds) to synchronize storage pool operations.", null),
|
||||
StorageTemplateCleanupEnabled("Storage", ManagementServer.class, Boolean.class, "storage.template.cleanup.enabled", "true", "Enable/disable template cleanup activity, only take effect when overall storage cleanup is enabled", null),
|
||||
|
||||
// Network
|
||||
NetworkLBHaproxyStatsVisbility("Network", ManagementServer.class, String.class, "network.loadbalancer.haproxy.stats.visibility", "global", "Load Balancer(haproxy) stats visibilty, it can be global,guest-network,disabled", null),
|
||||
|
||||
@ -295,6 +295,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
ScheduledExecutorService _executor = null;
|
||||
boolean _storageCleanupEnabled;
|
||||
boolean _templateCleanupEnabled = true;
|
||||
int _storageCleanupInterval;
|
||||
int _storagePoolAcquisitionWaitSeconds = 1800; // 30 minutes
|
||||
protected int _retry = 2;
|
||||
@ -809,9 +810,14 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
String storageCleanupEnabled = configs.get("storage.cleanup.enabled");
|
||||
_storageCleanupEnabled = (storageCleanupEnabled == null) ? true : Boolean.parseBoolean(storageCleanupEnabled);
|
||||
|
||||
|
||||
String value = configDao.getValue(Config.StorageTemplateCleanupEnabled.key());
|
||||
_templateCleanupEnabled = (value == null ? true : Boolean.parseBoolean(value));
|
||||
|
||||
String time = configs.get("storage.cleanup.interval");
|
||||
_storageCleanupInterval = NumbersUtil.parseInt(time, 86400);
|
||||
|
||||
s_logger.info("Storage cleanup enabled: " + _storageCleanupEnabled + ", interval: " + _storageCleanupInterval + ", template cleanup enabled: " + _templateCleanupEnabled);
|
||||
|
||||
String workers = configs.get("expunge.workers");
|
||||
int wrks = NumbersUtil.parseInt(workers, 10);
|
||||
@ -1913,31 +1919,33 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
if (scanLock.lock(3)) {
|
||||
try {
|
||||
// Cleanup primary storage pools
|
||||
List<StoragePoolVO> storagePools = _storagePoolDao.listAll();
|
||||
for (StoragePoolVO pool : storagePools) {
|
||||
try {
|
||||
|
||||
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());
|
||||
for (VMTemplateStoragePoolVO templatePoolVO : unusedTemplatesInPool) {
|
||||
if (templatePoolVO.getDownloadState() != VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
|
||||
s_logger.debug("Storage pool garbage collector is skipping templatePoolVO with ID: " + templatePoolVO.getId() + " because it is not completely downloaded.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!templatePoolVO.getMarkedForGC()) {
|
||||
templatePoolVO.setMarkedForGC(true);
|
||||
_vmTemplatePoolDao.update(templatePoolVO.getId(), templatePoolVO);
|
||||
s_logger.debug("Storage pool garbage collector has marked templatePoolVO with ID: " + templatePoolVO.getId() + " for garbage collection.");
|
||||
continue;
|
||||
}
|
||||
|
||||
_tmpltMgr.evictTemplateFromStoragePool(templatePoolVO);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Problem cleaning up primary storage pool " + pool, e);
|
||||
}
|
||||
}
|
||||
if(_templateCleanupEnabled) {
|
||||
List<StoragePoolVO> storagePools = _storagePoolDao.listAll();
|
||||
for (StoragePoolVO pool : storagePools) {
|
||||
try {
|
||||
|
||||
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());
|
||||
for (VMTemplateStoragePoolVO templatePoolVO : unusedTemplatesInPool) {
|
||||
if (templatePoolVO.getDownloadState() != VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
|
||||
s_logger.debug("Storage pool garbage collector is skipping templatePoolVO with ID: " + templatePoolVO.getId() + " because it is not completely downloaded.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!templatePoolVO.getMarkedForGC()) {
|
||||
templatePoolVO.setMarkedForGC(true);
|
||||
_vmTemplatePoolDao.update(templatePoolVO.getId(), templatePoolVO);
|
||||
s_logger.debug("Storage pool garbage collector has marked templatePoolVO with ID: " + templatePoolVO.getId() + " for garbage collection.");
|
||||
continue;
|
||||
}
|
||||
|
||||
_tmpltMgr.evictTemplateFromStoragePool(templatePoolVO);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Problem cleaning up primary storage pool " + pool, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup secondary storage hosts
|
||||
List<HostVO> secondaryStorageHosts = _hostDao.listSecondaryStorageHosts();
|
||||
|
||||
@ -17,3 +17,4 @@ ALTER TABLE `cloud`.`host` MODIFY `storage_ip_address` char(40);
|
||||
|
||||
INSERT IGNORE INTO configuration VALUES ('Network', 'DEFAULT', 'management-server', 'network.redundantrouter', 'false', 'enable/disable redundant virtual router');
|
||||
INSERT IGNORE INTO configuration VALUES ('Storage', 'DEFAULT', 'management-server', 'storage.pool.max.waitseconds', '3600', 'Timeout (in seconds) to synchronize storage pool operations.');
|
||||
INSERT IGNORE INTO configuration VALUES ('Storage', 'DEFAULT', 'management-server', 'storage.template.cleanup.enabled', 'true', 'Enable/disable template cleanup activity, only take effect when overall storage cleanup is enabled');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user