Skip to content

Commit b1b4250

Browse files
Preserve kernel-range form for Vips remoteports
The previous commit on this branch accidentally changed the Vips path in ResolveNFSTarget from "<startIP>-<endIP>" (kernel-range syntax that expands to every IP in the range) to "<startIP>,<endIP>" (just two IPs, comma-joined). That drops every IP between the endpoints and defeats the load-balancing the range form was emitting. The comma-joined form is correct for the new DNS-resolution output in materializeNFSTarget (which produces a list of discrete IPs from getaddrinfo). It is NOT correct for the Vips range, which is a 2-element [startIP, endIP] contract documented at ExpectedVIPRangeLen. Restore "<startIP>-<endIP>" for the 2-element case and "first-last" for the defensive >2 case. Update tests to match. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4836b97 commit b1b4250

2 files changed

Lines changed: 23 additions & 18 deletions

File tree

internal/crusoe/disk.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,16 @@ func CheckDiskMatchesRequest(disk *crusoeapi.DiskV1Alpha5,
165165
// authoritative VIP set from the storage API and bypasses OVN's DNS intercept,
166166
// which has produced ENOKEY, EPROTONOSUPPORT and the musl REFUSED failure
167167
// modes from INC-450 in production. When vips is populated we return the
168-
// full set joined by "," so the kernel's NFS client receives an explicit IP
169-
// list in remoteports= and never invokes the dns_resolver keyring upcall.
170-
// Only when vips is empty do we fall back to dns_name (which the caller will
171-
// resolve in-process before passing to mount).
168+
// kernel-range form "<startIP>-<endIP>" so remoteports= expands to every IP
169+
// in the range without invoking the dns_resolver keyring upcall. Only when
170+
// vips is empty do we fall back to dns_name (which the caller will resolve
171+
// in-process before passing to mount).
172172
//
173-
// Vips is contracted to be a 2-element [startIP, endIP] range; we tolerate
174-
// other lengths defensively but warn so the discrepancy is visible.
173+
// Vips is contracted to be a 2-element [startIP, endIP] range. We tolerate
174+
// other lengths defensively but warn so the discrepancy is visible. We do
175+
// NOT comma-join the range endpoints — comma-joining would yield only the
176+
// two endpoint IPs and drop every IP in between, defeating the load-balancing
177+
// the range is meant to provide.
175178
func ResolveNFSTarget(disk *crusoeapi.DiskV1Alpha5) (host, remotePorts string, ok bool) {
176179
if len(disk.Vips) > 0 {
177180
return resolveFromVIPs(disk)
@@ -183,25 +186,27 @@ func ResolveNFSTarget(disk *crusoeapi.DiskV1Alpha5) (host, remotePorts string, o
183186
return "", "", false
184187
}
185188

186-
// resolveFromVIPs builds an explicit IP-list remoteports string from a disk's
187-
// vips field. The first IP doubles as the mount-source host so busybox-mount
188-
// in the Alpine CSI pod never has to do its own getaddrinfo either.
189+
// resolveFromVIPs builds the kernel-range remoteports string ("startIP-endIP")
190+
// from a disk's vips field. The first IP doubles as the mount-source host so
191+
// busybox-mount in the Alpine CSI pod never has to do its own getaddrinfo
192+
// either. The hyphenated range form is parsed by the Linux NFS client and
193+
// expanded to every IP between start and end inclusive.
189194
func resolveFromVIPs(disk *crusoeapi.DiskV1Alpha5) (host, remotePorts string, ok bool) {
190195
switch len(disk.Vips) {
191196
case 0:
192197
return "", "", false
193198
case ExpectedVIPRangeLen:
194-
return disk.Vips[0], strings.Join(disk.Vips, ","), true
199+
return disk.Vips[0], fmt.Sprintf("%s-%s", disk.Vips[0], disk.Vips[1]), true
195200
case 1:
196201
klog.Warningf("disk %s returned %d vip(s), expected %d ([startIP, endIP]); using single vip %q",
197202
disk.Id, len(disk.Vips), ExpectedVIPRangeLen, disk.Vips[0])
198203

199204
return disk.Vips[0], disk.Vips[0], true
200205
default:
201-
klog.Warningf("disk %s returned %d vips, expected %d ([startIP, endIP]); joining all into remoteports",
202-
disk.Id, len(disk.Vips), ExpectedVIPRangeLen)
206+
klog.Warningf("disk %s returned %d vips, expected %d ([startIP, endIP]); using first and last %q-%q",
207+
disk.Id, len(disk.Vips), ExpectedVIPRangeLen, disk.Vips[0], disk.Vips[len(disk.Vips)-1])
203208

204-
return disk.Vips[0], strings.Join(disk.Vips, ","), true
209+
return disk.Vips[0], fmt.Sprintf("%s-%s", disk.Vips[0], disk.Vips[len(disk.Vips)-1]), true
205210
}
206211
}
207212

internal/crusoe/disk_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ func TestResolveNFSTarget(t *testing.T) {
3838
Vips: []string{"1.2.3.4", "1.2.3.8"},
3939
},
4040
wantHost: "1.2.3.4",
41-
wantRemotePorts: "1.2.3.4,1.2.3.8",
41+
wantRemotePorts: "1.2.3.4-1.2.3.8",
4242
wantOK: true,
4343
},
4444
{
45-
name: "vip range produces comma-joined remoteports",
45+
name: "vip range produces kernel-range remoteports",
4646
disk: crusoeapi.DiskV1Alpha5{Vips: []string{"1.2.3.4", "1.2.3.8"}},
4747
wantHost: "1.2.3.4",
48-
wantRemotePorts: "1.2.3.4,1.2.3.8",
48+
wantRemotePorts: "1.2.3.4-1.2.3.8",
4949
wantOK: true,
5050
},
5151
{
@@ -56,10 +56,10 @@ func TestResolveNFSTarget(t *testing.T) {
5656
wantOK: true,
5757
},
5858
{
59-
name: "more than two vips joins the entire list",
59+
name: "more than two vips uses first and last as range endpoints",
6060
disk: crusoeapi.DiskV1Alpha5{Vips: []string{"1.2.3.4", "1.2.3.5", "1.2.3.8"}},
6161
wantHost: "1.2.3.4",
62-
wantRemotePorts: "1.2.3.4,1.2.3.5,1.2.3.8",
62+
wantRemotePorts: "1.2.3.4-1.2.3.8",
6363
wantOK: true,
6464
},
6565
}

0 commit comments

Comments
 (0)