Skip to content

Commit c50723f

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
test 2
1 parent 6508e45 commit c50723f

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/IscsiAdmStorageAdaptor.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,31 @@ public KVMPhysicalDisk createPhysicalDisk(String volumeUuid, KVMStoragePool pool
8787

8888
@Override
8989
public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<String, String> details, boolean isVMMigrate) {
90+
logger.info("connectPhysicalDisk called: volumeUuid={}, pool.host={}, pool.port={}, pool.uuid={}",
91+
volumeUuid, pool.getSourceHost(), pool.getSourcePort(), pool.getUuid());
92+
9093
// ex. sudo iscsiadm -m node -T iqn.2012-03.com.test:volume1 -p 192.168.233.10:3260 -o new
94+
String iqnTarget = getIqn(volumeUuid);
95+
logger.info("Parsed IQN from volumeUuid: {}", iqnTarget);
96+
9197
Script iScsiAdmCmd = new Script(true, "iscsiadm", 0, logger);
9298

9399
iScsiAdmCmd.add("-m", "node");
94-
iScsiAdmCmd.add("-T", getIqn(volumeUuid));
100+
iScsiAdmCmd.add("-T", iqnTarget);
95101
iScsiAdmCmd.add("-p", pool.getSourceHost() + ":" + pool.getSourcePort());
96102
iScsiAdmCmd.add("-o", "new");
97103

104+
logger.info("Executing: iscsiadm -m node -T {} -p {}:{} -o new", iqnTarget, pool.getSourceHost(), pool.getSourcePort());
98105
String result = iScsiAdmCmd.execute();
106+
logger.info("iscsiadm -o new result: {}", result == null ? "SUCCESS (null)" : result);
99107

100108
if (result != null) {
101109
// Node record may already exist from a previous run; accept and proceed
102110
if (isNonFatalNodeCreate(result)) {
103111
logger.debug("iSCSI node already exists for {}@{}:{}, proceeding", getIqn(volumeUuid), pool.getSourceHost(), pool.getSourcePort());
112+
logger.info("iSCSI node already exists (non-fatal), proceeding");
104113
} else {
114+
logger.info("Failed to add iSCSI target {}: {}", volumeUuid, result);
105115
logger.debug("Failed to add iSCSI target " + volumeUuid);
106116
System.out.println("Failed to add iSCSI target " + volumeUuid);
107117

@@ -126,6 +136,7 @@ public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<S
126136
// ex. sudo iscsiadm -m node -T iqn.2012-03.com.test:volume1 -p 192.168.233.10:3260 --op update -n node.session.auth.password -v password
127137
executeChapCommand(volumeUuid, pool, "node.session.auth.password", chapInitiatorSecret, "password");
128138
} catch (Exception ex) {
139+
logger.info("CHAP configuration failed for volumeUuid={}: {}", volumeUuid, ex.getMessage());
129140
return false;
130141
}
131142
}
@@ -141,12 +152,16 @@ public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<S
141152
iScsiAdmCmd.add("-p", host + ":" + port);
142153
iScsiAdmCmd.add("--login");
143154

155+
logger.info("Executing: iscsiadm -m node -T {} -p {}:{} --login", iqn, host, port);
144156
result = iScsiAdmCmd.execute();
157+
logger.info("iscsiadm --login result: {}", result == null ? "SUCCESS (null)" : result);
145158

146159
if (result != null) {
147160
if (isNonFatalLogin(result)) {
148161
logger.debug("iSCSI login returned benign message for {}@{}:{}: {}", iqn, host, port, result);
162+
logger.info("iSCSI login returned benign message (non-fatal), proceeding");
149163
} else {
164+
logger.info("Failed to log in to iSCSI target {}: {}", volumeUuid, result);
150165
logger.debug("Failed to log in to iSCSI target " + volumeUuid + ": " + result);
151166
System.out.println("Failed to log in to iSCSI target " + volumeUuid);
152167

@@ -167,8 +182,10 @@ public boolean connectPhysicalDisk(String volumeUuid, KVMStoragePool pool, Map<S
167182
// After a certain number of tries and a certain waiting period in between tries,
168183
// this method could still return (it should not block indefinitely) (the race condition
169184
// isn't solved here, but made highly unlikely to be a problem).
185+
logger.info("Waiting for disk to become available: volumeUuid={}", volumeUuid);
170186
waitForDiskToBecomeAvailable(volumeUuid, pool);
171187

188+
logger.info("connectPhysicalDisk completed successfully for volumeUuid={}", volumeUuid);
172189
return true;
173190
}
174191

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/listener/OntapHostListener.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.cloud.agent.api.Answer;
3434
import com.cloud.agent.api.DeleteStoragePoolCommand;
3535
import com.cloud.host.Host;
36+
import com.cloud.storage.Storage.StoragePoolType;
3637
import com.cloud.storage.StoragePool;
3738
import com.cloud.utils.exception.CloudRuntimeException;
3839
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
@@ -82,7 +83,17 @@ public boolean hostConnect(long hostId, long poolId) {
8283
// Create the ModifyStoragePoolCommand to send to the agent
8384
// Note: Always send command even if database entry exists, because agent may have restarted
8485
// and lost in-memory pool registration. The command handler is idempotent.
85-
ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, pool, detailsMap);
86+
// For managed iSCSI pools, no local mount path is needed (null), only NFS pools need mount points
87+
ModifyStoragePoolCommand cmd;
88+
if (pool.getPoolType() == StoragePoolType.Iscsi) {
89+
// iSCSI managed storage: no mount point, pass null for localPath
90+
cmd = new ModifyStoragePoolCommand(true, pool, null, detailsMap);
91+
logger.debug("Creating ModifyStoragePoolCommand for iSCSI pool {} without localPath", pool.getName());
92+
} else {
93+
// NFS/Other storage: use default mount path generation
94+
cmd = new ModifyStoragePoolCommand(true, pool, detailsMap);
95+
logger.debug("Creating ModifyStoragePoolCommand for {} pool {} with auto-generated localPath", pool.getPoolType(), pool.getName());
96+
}
8697

8798
Answer answer = _agentMgr.easySend(hostId, cmd);
8899

@@ -107,19 +118,25 @@ public boolean hostConnect(long hostId, long poolId) {
107118
}
108119

109120
String localPath = poolInfo.getLocalPath();
110-
logger.info("Storage pool {} successfully mounted at: {}", pool.getName(), localPath);
121+
if (pool.getPoolType() == StoragePoolType.Iscsi) {
122+
// iSCSI pools don't have mount points
123+
logger.info("Storage pool {} successfully registered (iSCSI managed storage, no mount point)", pool.getName());
124+
} else {
125+
logger.info("Storage pool {} successfully mounted at: {}", pool.getName(), localPath);
126+
}
111127

112-
// Update or create the storage_pool_host_ref entry with the correct local_path
128+
// Update or create the storage_pool_host_ref entry
129+
// For iSCSI pools, localPath may be null (no mount point)
113130
StoragePoolHostVO storagePoolHost = storagePoolHostDao.findByPoolHost(poolId, hostId);
114131

115132
if (storagePoolHost == null) {
116133
storagePoolHost = new StoragePoolHostVO(poolId, hostId, localPath);
117134
storagePoolHostDao.persist(storagePoolHost);
118-
logger.info("Created storage_pool_host_ref entry for pool {} and host {}", pool.getName(), host.getName());
135+
logger.info("Created storage_pool_host_ref entry for pool {} and host {} with localPath: {}", pool.getName(), host.getName(), localPath);
119136
} else {
120137
storagePoolHost.setLocalPath(localPath);
121138
storagePoolHostDao.update(storagePoolHost.getId(), storagePoolHost);
122-
logger.info("Updated storage_pool_host_ref entry with local_path: {}", localPath);
139+
logger.info("Updated storage_pool_host_ref entry for pool {} with localPath: {}", pool.getName(), localPath);
123140
}
124141

125142
// Update pool capacity/usage information

0 commit comments

Comments
 (0)