mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
iscsi session cleanup now configurable, filters iscsi partitions (#4219)
Added property to agent.properties that enables or disables the iscsi session clean up feature. #4210 Added a condition to prevent disk partitions from being cleaned up. #4216
This commit is contained in:
parent
86939e7f9d
commit
1da76d27f1
@ -218,3 +218,8 @@ hypervisor.type=kvm
|
||||
# timer.
|
||||
# For all actions refer to the libvirt documentation.
|
||||
# Recommended values are: none, reset and poweroff.
|
||||
#
|
||||
iscsi.session.cleanup.enabled=false
|
||||
# Automatically clean up iscsi sessions not attached to any VM.
|
||||
# Should be enabled for users using managed storage for example solidfire.
|
||||
# Should be disabled for users with unmanaged iscsi connections on their hosts
|
||||
|
||||
@ -61,6 +61,7 @@ import org.apache.cloudstack.utils.security.KeyStoreUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.joda.time.Duration;
|
||||
@ -1088,9 +1089,15 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
storageProcessor.configure(name, params);
|
||||
storageHandler = new StorageSubsystemCommandHandlerBase(storageProcessor);
|
||||
|
||||
Boolean _iscsiCleanUpEnabled = Boolean.parseBoolean((String)params.get("iscsi.session.cleanup.enabled"));
|
||||
|
||||
if (BooleanUtils.isTrue(_iscsiCleanUpEnabled)) {
|
||||
IscsiStorageCleanupMonitor isciCleanupMonitor = new IscsiStorageCleanupMonitor();
|
||||
final Thread cleanupMonitor = new Thread(isciCleanupMonitor);
|
||||
cleanupMonitor.start();
|
||||
} else {
|
||||
s_logger.info("iscsi session clean up is disabled");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ public class IscsiStorageCleanupMonitor implements Runnable{
|
||||
private static final String ISCSI_PATH_PREFIX = "/dev/disk/by-path";
|
||||
private static final String KEYWORD_ISCSI = "iscsi";
|
||||
private static final String KEYWORD_IQN = "iqn";
|
||||
private static final String REGEX_PART = "\\S+part\\d+$";
|
||||
|
||||
private IscsiAdmStorageAdaptor iscsiStorageAdaptor;
|
||||
|
||||
@ -114,7 +115,7 @@ public class IscsiStorageCleanupMonitor implements Runnable{
|
||||
|
||||
//check the volume map. If an entry exists change the status to True
|
||||
for (final LibvirtVMDef.DiskDef disk : disks) {
|
||||
if (diskStatusMap.containsKey(disk.getDiskPath())) {
|
||||
if (diskStatusMap.containsKey(disk.getDiskPath())&&!disk.getDiskPath().matches(REGEX_PART)) {
|
||||
diskStatusMap.put(disk.getDiskPath(), true);
|
||||
s_logger.debug("active disk found by cleanup thread" + disk.getDiskPath());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user