Skip to content

Commit 9b6d304

Browse files
CANARY (DO NOT MERGE): force userspace DNS path on + strace the fs mount
Throwaway instrumentation to validate the NFS mount end to end in a test cluster, off the CRUSOE-70481 branch: - userspaceDNSResolutionEnabled() forced to true, simulating the feature flag rolled out (the flag endpoint is not deployed in the test env, so the real fetch would 404 -> false). - fs node Mounter wrapped (straceMountExec) so `mount` runs under strace, writing the trace to /tmp/crusoe-mount-strace-<ts>.log -- captures the mount(2) source/options and the connect() targets the kernel dials. - strace added to the runtime image. DO NOT MERGE. This branch exists only to build a canary image for e2e testing.
1 parent b7be1bf commit 9b6d304

4 files changed

Lines changed: 65 additions & 17 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ RUN apk upgrade --no-cache && \
3030
apk add --no-cache e2fsprogs-extra~=1.47.0 && \
3131
apk add --no-cache blkid~=2.40.1 && \
3232
apk add --no-cache xfsprogs-extra~=6.8.0 && \
33+
apk add --no-cache strace && \
3334
rm -rf /var/cache/apk/*
3435

3536
COPY --from=builder /build/dist/crusoe-csi-driver /usr/local/go/bin/crusoe-csi-driver

internal/node/fs/fs_node.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,14 @@ func (d *Node) fetchDiskOrNil(
182182
}
183183

184184
// userspaceDNSResolutionEnabled reports whether the project has opted into
185-
// CSI-side NFS DNS resolution. It defaults to false (legacy behaviour) on any
186-
// flag-fetch error, so an unreachable or not-yet-deployed flag endpoint keeps
187-
// today's behaviour.
188-
func (d *Node) userspaceDNSResolutionEnabled(ctx context.Context) bool {
189-
enabled, err := crusoe.GetUserspaceDNSResolutionFlag(
190-
ctx, d.CrusoeHTTPClient, d.CrusoeAPIEndpoint, d.HostInstance.ProjectId)
191-
if err != nil {
192-
klog.Warningf("failed to fetch userspace-DNS-resolution flag, defaulting to legacy resolution: %s",
193-
err.Error())
194-
195-
return false
196-
}
197-
198-
return enabled
185+
// CSI-side NFS DNS resolution.
186+
//
187+
// CANARY (DO NOT MERGE): forced to true to simulate the feature flag rolled out.
188+
// The real implementation fetches GetUserspaceDNSResolutionFlag and defaults to
189+
// false on error; here the flag endpoint is not deployed in the test env, so we
190+
// short-circuit to exercise the userspace path end to end.
191+
func (d *Node) userspaceDNSResolutionEnabled(_ context.Context) bool {
192+
return true
199193
}
200194

201195
// legacyResolveNFSTarget reproduces the previously-released resolution exactly:

internal/server.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ func registerNode(grpcServer *grpc.Server, hostInstance *crusoeapi.InstanceV1Alp
8585
case common.DiskTypeFS:
8686
maxVolumesPerNode = common.MaxFSVolumesPerNode
8787
nodeServer = &fs.Node{
88-
CrusoeClient: newCrusoeClientWithViperConfig(),
89-
CrusoeHTTPClient: newCrusoeHTTPClientWithViperConfig(),
90-
Mounter: mount.NewSafeFormatAndMount(mount.New(""), exec.New()),
88+
CrusoeClient: newCrusoeClientWithViperConfig(),
89+
CrusoeHTTPClient: newCrusoeHTTPClientWithViperConfig(),
90+
// CANARY (DO NOT MERGE): strace-wrap the fs mount for e2e validation.
91+
Mounter: mount.NewSafeFormatAndMount(mount.New(""), straceMountExec{exec.New()}),
9192
Resizer: mount.NewResizeFs(exec.New()),
9293
CrusoeAPIEndpoint: viper.GetString(CrusoeAPIEndpointFlag),
9394
NFSRemotePorts: viper.GetString(NFSRemotePortsFlag),

internal/strace_mount_canary.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package internal
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"time"
7+
8+
"k8s.io/klog/v2"
9+
"k8s.io/utils/exec"
10+
)
11+
12+
// straceMountExec is CANARY INSTRUMENTATION — DO NOT MERGE.
13+
//
14+
// It wraps an exec.Interface so the fs node's `mount` command runs under strace,
15+
// writing a per-mount trace to a file. It exists only to validate the NFS mount
16+
// end to end during canary testing — the mount(2) source/options and the
17+
// connect() targets the kernel actually dials. Requires `strace` in the runtime
18+
// image. Non-mount commands pass through unchanged.
19+
type straceMountExec struct {
20+
exec.Interface
21+
}
22+
23+
func (e straceMountExec) Command(cmd string, args ...string) exec.Cmd {
24+
if cmd == "mount" {
25+
return e.Interface.Command("strace", straceMountArgs(args)...)
26+
}
27+
28+
return e.Interface.Command(cmd, args...)
29+
}
30+
31+
func (e straceMountExec) CommandContext(ctx context.Context, cmd string, args ...string) exec.Cmd {
32+
if cmd == "mount" {
33+
return e.Interface.CommandContext(ctx, "strace", straceMountArgs(args)...)
34+
}
35+
36+
return e.Interface.CommandContext(ctx, cmd, args...)
37+
}
38+
39+
func straceMountArgs(mountArgs []string) []string {
40+
logPath := fmt.Sprintf("/tmp/crusoe-mount-strace-%d.log", time.Now().UnixNano())
41+
klog.Warningf("CANARY: tracing mount under strace -> %s", logPath)
42+
43+
// -f follows mount.nfs forks; -tt timestamps; -s 512 keeps long mount-option
44+
// strings intact; connect/sendto/sendmsg show the IPs the kernel dials.
45+
straceArgs := []string{
46+
"-f", "-tt", "-s", "512",
47+
"-e", "trace=mount,connect,sendto,sendmsg",
48+
"-o", logPath, "mount",
49+
}
50+
51+
return append(straceArgs, mountArgs...)
52+
}

0 commit comments

Comments
 (0)