Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions agent/conf/agent.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
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;
Expand Down Expand Up @@ -1088,9 +1089,15 @@ public boolean configure(final String name, final Map<String, Object> params) th
storageProcessor.configure(name, params);
storageHandler = new StorageSubsystemCommandHandlerBase(storageProcessor);

IscsiStorageCleanupMonitor isciCleanupMonitor = new IscsiStorageCleanupMonitor();
final Thread cleanupMonitor = new Thread(isciCleanupMonitor);
cleanupMonitor.start();
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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+$";
Copy link
Member

@mike-tutkowski mike-tutkowski Jul 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we want to use KEYWORD_PART here instead of "part"?


private IscsiAdmStorageAdaptor iscsiStorageAdaptor;

Expand Down Expand Up @@ -114,7 +115,7 @@ private void updateDiskStatusMapWithInactiveIscsiSessions(Connect conn){

//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());
}
Expand Down