refactor: localize Viperblockd NBD transport

This commit is contained in:
joshsiv-mulga
2026-10-01 08:43:20 +10:00
parent f4cb550c94
commit adb55de33e
7 changed files with 24 additions and 13 deletions
+1
View File
@@ -189,6 +189,7 @@ while the branch is in flight; they do not describe the umbrella repository's
| `78fd017e0` | `spinifex/types/telemetry.go` (`GuestTelemetryMeta`) | `contracts/telemetry/v1/guest_meta.go` | QMP collector sidecar JSON is a versioned file contract between VM runtime and telemetry role; `guest_meta_test.go` pins its filename and payload. |
| `4b35a2a33` | `spinifex/types/node.go` (`NodeVMsResponse`, `VMInfo`, `VMGPUInfo`) | `contracts/cluster/v1/node_vms.go` | VM inventory is a versioned cluster fan-out payload used by SPX CLI and EKS host lookup; `node_vms_test.go` pins its subject and JSON shape. |
| `08bd335f0` | `spinifex/types/node.go` (`NodeStatusResponse`, capacity and GPU inventory) | `contracts/cluster/v1/status.go` | Node status is a versioned fan-out observation contract for operator inspection and EC2/EKS scheduling consumers; `status_test.go` pins its subject and JSON shape. |
| `f4cb550c9` | `spinifex/types/ebs.go` (GP3 policy constants) | `spinifex/domains/ec2/ebs/policy/gp3.go` | The supported GP3 product envelope is EC2 EBS domain policy, not generic runtime or Viperblockd wire state; `gp3_test.go` pins the deployed values. |
The EC2 contract row is intentionally different from the directory moves: it creates
a compatibility boundary. `ec2.cmd.*` retains its deployed one-token NATS
@@ -74,7 +74,7 @@ func inProcessProvider(t *testing.T) (func(t *testing.T) ebsprovider.EBSProvider
cfg.AccessKey = fixture.AccessKey
cfg.SecretKey = fixture.SecretKey
cfg.PluginPath = pluginPath
cfg.NBDTransport = types.NBDTransportTCP
cfg.NBDTransport = NBDTransportTCP
cfg.NodeName = name
// The lease owner is derived from NodeName, and setupTestConfig built
// the store before this function could set it. Rebuild it, or both
@@ -0,0 +1,11 @@
package viperblockd
// NBDTransport controls how Viperblockd exports a mounted volume.
type NBDTransport string
const (
// NBDTransportSocket uses Unix domain sockets (faster, local only).
NBDTransportSocket NBDTransport = "socket"
// NBDTransportTCP uses TCP connections (required for remote/DPU scenarios).
NBDTransportTCP NBDTransport = "tcp"
)
@@ -0,0 +1,9 @@
package viperblockd
import "testing"
func TestNBDTransportValues(t *testing.T) {
if NBDTransportSocket != "socket" || NBDTransportTCP != "tcp" {
t.Fatal("unexpected NBD transport values")
}
}
@@ -1408,7 +1408,7 @@ func mountVolume(ctx context.Context, cfg *Config, nc *nats.Conn, volumeName str
mountSpan.SetAttributes(attribute.Int64("volume.size_bytes", safecast.Uint64ToInt64(vb.GetVolumeSize())))
useTCP := cfg.NBDTransport == types.NBDTransportTCP
useTCP := cfg.NBDTransport == NBDTransportTCP
var nbdURI string
var nbdSocket string
+1 -1
View File
@@ -149,7 +149,7 @@ type Config struct {
// NBDTransport controls the transport type: "socket" (default) or "tcp"
// Socket is faster for local connections, TCP required for remote/DPU scenarios
NBDTransport types.NBDTransport
NBDTransport NBDTransport
// ShardWAL enables sharded WAL for mounted volumes (default false)
ShardWAL bool
-10
View File
@@ -24,16 +24,6 @@ type EBSRequest struct {
HotplugPort int `json:"HotplugPort,omitempty"`
}
// NBDTransport defines the transport type for NBD connections.
type NBDTransport string
const (
// NBDTransportSocket uses Unix domain sockets (faster, local only).
NBDTransportSocket NBDTransport = "socket"
// NBDTransportTCP uses TCP connections (required for remote/DPU scenarios).
NBDTransportTCP NBDTransport = "tcp"
)
type EBSMountResponse struct {
URI string `json:"URI"`
Mounted bool `json:"Mounted"`