← Back to Pull requests

Fix IPv6 portal parsing in connectTarget and Disconnect #102

Open
unknown opened this pull request with 494 lines diff across 6 files
View on GitHub
unknown unknown commented on Aug 03, 2026 10:19 UTC
Author

Fixes #94

connectTarget parsed the portal with strings.Split(target, ":") and took field [0] as the host and [1] as the port. For an IPv6 portal that splits mid-address, and the mangled parts were then rejoined to build the /dev/disk/by-path/ip-... path, which could never match the udev symlink. Disconnect took the host the same way and passed an unbracketed IPv6 literal to iscsiadm.

This adds parsePortal, using net.SplitHostPort with a fallback to defaultPort when the portal carries no port, and bracketHost for the call sites that hand a host to iscsiadm. As @estenrye points out in the issue, the two representations genuinely differ and both are needed: iscsiadm expects a bracketed IPv6 literal, while udev names the by-path link with the bare one.

Before / after, running the old and new parsing over the same inputs and showing the by-path that gets constructed:

PORTAL                     OLD by-path (broken)                       NEW by-path (fixed)
--------------------------------------------------------------------------------------------
192.168.1.1:3260           ip-192.168.1.1:3260-iscsi-...              ip-192.168.1.1:3260-iscsi-...        same
192.168.1.1                ip-192.168.1.1:3260-iscsi-...              ip-192.168.1.1:3260-iscsi-...        same
target.example.com:3260    ip-target.example.com:3260-iscsi-...       ip-target.example.com:3260-iscsi-... same
[2001:db8::1]:3260         ip-[2001:db8-iscsi-...                     ip-2001:db8::1:3260-iscsi-...        CHANGED
[2001:db8::1]              ip-[2001:db8-iscsi-...                     ip-2001:db8::1:3260-iscsi-...        CHANGED
2001:db8::1                ip-2001:db8-iscsi-...                      ip-2001:db8::1:3260-iscsi-...        CHANGED

IPv4 and hostname portals are byte-identical before and after. Only IPv6 inputs change, and they change from unusable to correct.

Testing

Test_parsePortal covers IPv4 with and without a port, a hostname, and IPv6 bracketed with a port, bracketed without one, and bare. Each case asserts both representations — the bare host:port that goes into the by-path link and the net.JoinHostPort form that goes to iscsiadm. Test_bracketHost covers the bracketing helper.

go test ./... passes, go vet is clean, and both changed files are gofmt clean. (iscsi/iscsiadm.go is reported unformatted by gofmt -l, but that is pre-existing on master and untouched here.)

One judgement call worth flagging

A bare, unbracketed IPv6 portal with a port appended — 2001:db8::1:3260 — is genuinely ambiguous: it is also a syntactically valid IPv6 address. net.SplitHostPort rejects it, so this change treats the whole string as the host and applies defaultPort. The reference implementation linked in the issue uses lastIndexOf(":") instead, which would read the last field as a port but then mis-parses a bare IPv6 address with no port. I went with the unambiguous reading, which is also what the issue's own proposed fix suggests, but I am happy to switch if you would rather match democratic-csi's behaviour.

What I did and did not verify

I do not have an IPv6-only iSCSI target, so I have not reproduced the original end-to-end failure or confirmed the fix against real hardware. What I verified is the parsing and the constructed device path, by unit test and by running the old and new logic side by side, as shown above. The end-to-end evidence in the issue is @estenrye's.

Disclosure: an AI assistant helped me trace the call path and draft the tests. The before/after table is output I ran, and I checked the code paths in the tree myself.

``release-note
Fix IPv6 iSCSI portal parsing.
connectTarget and Disconnect split the portal on every :, mangling IPv6 addresses so the constructed /dev/disk/by-path link never matched and Connect failed with "failed to find device path". IPv4 and hostname portals are unaffected.
``

Diff: 494 lines (+370 / -124) across 6 files Reviewer: kginonredhat Review duration: 99553m
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.54) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.54 · 494 lines diff across 6 files
0.54
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
44%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.371
Shallow Review Depth shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #102"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 44.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 54.4% (MEDIUM) · Higher = larger blast radius
54.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 44.7% · Lower = rushed or shallow review
44.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 30.1% · Safe to merge
30.1%