Subsequent VM Creation is failing for ISCSI Storage Pool on Oracle Linux - #88
Subsequent VM Creation is failing for ISCSI Storage Pool on Oracle Linux#88suryag1201 wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses failures when creating subsequent VMs on iSCSI primary storage with KVM (notably on Oracle Linux) by making iSCSI login/rescan behavior more robust and adding additional readiness checks before proceeding.
Changes:
- Adds explicit handling for iscsiadm exit codes and a pre-login session existence check to decide when a rescan is needed.
- Updates iSCSI login result handling to be idempotent across distros (Ubuntu vs Oracle Linux behavior) and triggers rescans when a session pre-exists.
- Adds extra validation for device readiness and improves by-path filesystem checks before calling
blockdev.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/IscsiAdmStorageAdaptor.java:177
- The warning uses
volumeUuidas the “target” identifier, but the log message is about the iSCSI target/portal; this can be misleading when troubleshooting. Use the computed IQN (iqn) in the message (and optionally include the volume path separately).
if (getPhysicalDisk(volumeUuid, pool).getSize() <= 0) {
logger.warn("iSCSI device not ready for target {} at {}:{} after wait", volumeUuid, host, port);
return false;
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/IscsiAdmStorageAdaptor.java:366
Files.isRegularFile(devicePath)follows symlinks by default, so a by-path symlink that (incorrectly) points to a regular file will be reported as a “regular file at by-path”, and the subsequentisSymbolicLinkcheck becomes unreachable in that case. CheckisSymbolicLinkfirst, or useNOFOLLOW_LINKSto test the path itself.
if (Files.isRegularFile(devicePath)) {
logger.warn("Found a corrupt regular file at iSCSI by-path {} (expected block device symlink); it must be removed manually", deviceByPath);
return 0L;
}
if (!Files.isSymbolicLink(devicePath)) {
🔴 Test Coverage Grade:
|
| Metric | Value |
|---|---|
| Line coverage | 24.58% |
| Branch coverage | 18.75% |
Grade Scale
| Grade | Line Coverage | Meaning |
|---|---|---|
| 🟢 A | ≥ 80% | Excellent - this code sleeps well at night 😴 |
| 🟡 B | 60-79% | Good - almost there, don't stop now 😉 |
| 🟠 C | 40-59% | Acceptable - your code is wearing a seatbelt, but no airbags 😬 |
| 🔴 D | 20-39% | Marginal - boldly shipping where no test has gone before 🖖 |
| ⛔ F | < 20% | Failing - tests? what tests? 🔥 |
Branch coverage is shown as a secondary signal. Grade is determined by line coverage.
View full Actions run
|
|
||
| OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser(); | ||
|
|
||
| sessionCmd.executeIgnoreExitValue(parser, ISCSI_ERR_NO_OBJS_FOUND); |
There was a problem hiding this comment.
Would it be possible to have this code ISCSI_SESSION_EXISTS_CODE check here itself? Instead of having a separate check in ln 147?
|
|
||
| String portal = host + ":" + port; | ||
|
|
||
| for (String line : sessions.split("\n")) { |
There was a problem hiding this comment.
as per this method, session is active if you see a any output line containing iqn and portal but we are parsing it using "\n". How are we sure if this parsing will not break on different OS flavour ?
There was a problem hiding this comment.
Line splitting on "\n" is safe here and not OS-dependent.
isIscsiSessionActive() does not parse raw iscsiadm bytes with native line endings. Output goes through OutputInterpreter.AllLinesParser, which uses BufferedReader.readLine() (handles \n, \r\n, and \r) and then rejoins lines with "\n":
| logger.debug("Device by-path does not exist yet: {}", deviceByPath); | ||
| return 0L; | ||
| } | ||
| if (Files.isRegularFile(devicePath)) { |
There was a problem hiding this comment.
how is this change required for ubuntu vs linux ?or is it agnostic to that ?
There was a problem hiding this comment.
this change is not Ubuntu-vs-Linux/Oracle specific
🔴 Test Coverage Grade:
|
| Metric | Value |
|---|---|
| Line coverage | 24.57% |
| Branch coverage | 18.75% |
Grade Scale
| Grade | Line Coverage | Meaning |
|---|---|---|
| 🟢 A | ≥ 80% | Excellent - this code sleeps well at night 😴 |
| 🟡 B | 60-79% | Good - almost there, don't stop now 😉 |
| 🟠 C | 40-59% | Acceptable - your code is wearing a seatbelt, but no airbags 😬 |
| 🔴 D | 20-39% | Marginal - boldly shipping where no test has gone before 🖖 |
| ⛔ F | < 20% | Failing - tests? what tests? 🔥 |
Branch coverage is shown as a secondary signal. Grade is determined by line coverage.
View full Actions run
| OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser(); | ||
| sessionCmd.executeIgnoreExitValue(parser, ISCSI_ERR_NO_OBJS_FOUND); | ||
| int exitValue = sessionCmd.getExitValue(); | ||
| if (exitValue != 0 && exitValue != ISCSI_ERR_NO_OBJS_FOUND) { |
There was a problem hiding this comment.
We are anyways ignoring ISCSI_ERR_NO_OBJS_FOUND in sessionCmd.executeIgnoreExitValue(parser, ISCSI_ERR_NO_OBJS_FOUND);, so, maybe we can remove this recheck
There was a problem hiding this comment.
executeIgnoreExitValue only allows exit 21 in addition to 0 so “no sessions” is not treated as a Script failure.
If we do not put, we will see the exception in the logs if there is no existing session. Please check this bug, i have updated the logs https://jira.ngage.netapp.com/browse/CSTACKEX-233
Above check is required to handle other exits code.
| Thread.sleep(timeBetweenTries); | ||
| } catch (Exception ex) { | ||
| // don't do anything | ||
| } catch (InterruptedException ex) { |
There was a problem hiding this comment.
Why is it important for us to handle an exception due to interruption? Do we get any additional info from this while debugging?
There was a problem hiding this comment.
We handle InterruptedException because Thread.sleep() can throw it when the thread is interrupted. In that case we stop waiting and fail the connect immediately, instead of continuing retries until the timeout.
| // this method could still return (it should not block indefinitely) (the race condition | ||
| // isn't solved here, but made highly unlikely to be a problem). | ||
| waitForDiskToBecomeAvailable(volumeUuid, pool); | ||
| if (!waitForDiskToBecomeAvailable(volumeUuid, pool)) { |
There was a problem hiding this comment.
They have mentioned in the comment that there could be a race condition between iSCSI login and device discovery. Unfortunately, this change doesn't seem to be fixing the race-condition, rather adding a strict check in waitForDiskToBecomeAvailable for device availability. Please see if this could be modified.
There was a problem hiding this comment.
The race, login success before the by-path device appears is still addressed by the existing retry loop in waitForDiskToBecomeAvailable, but this can still happen (rare case). Previously, after timeout with size 0, connectPhysicalDisk still returned true. Now it returns false so we don’t treat an unavailable disk as a successful connect and end up creating a raw file.
Also, Will wait for community reply on this change
Description
Subsequent VM Creation is failing for ISCSI Storage Pool on Oracle Linux
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Tested on both Oracle and Unbuntu and tried creating multiple VMs
How did you try to break this feature and the system with this change?