From d20fcd2c38fa2cbad41eb2f930e9d10333147998 Mon Sep 17 00:00:00 2001 From: Julian Sommer <115516918+juliansommer@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:43:50 +1000 Subject: [PATCH] fix merge --- hive/types/cluster.go | 43 ++++++++++++++++++++++++++ hive/types/ebs.go | 72 +++++++++++++++++++++++++++++++++++++++++++ hive/types/node.go | 48 +++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 hive/types/cluster.go create mode 100644 hive/types/ebs.go create mode 100644 hive/types/node.go diff --git a/hive/types/cluster.go b/hive/types/cluster.go new file mode 100644 index 000000000..eea279f11 --- /dev/null +++ b/hive/types/cluster.go @@ -0,0 +1,43 @@ +package types + +import "github.com/mulgadc/hive/hive/config" + +// Cluster manager API types + +type NodeJoinRequest struct { + Node string `json:"node"` + Region string `json:"region"` + AZ string `json:"az"` + DataDir string `json:"data_dir"` + DaemonHost string `json:"daemon_host"` // Host:port where this node's daemon is accessible +} + +// SharedClusterData contains only the shared cluster information (no node-specific top-level fields) +type SharedClusterData struct { + Epoch uint64 `json:"epoch" toml:"epoch"` + Version string `json:"version" toml:"version"` + Nodes map[string]config.Config `json:"nodes" toml:"nodes"` +} + +type NodeJoinResponse struct { + Success bool `json:"success"` + Message string `json:"message"` + SharedData *SharedClusterData `json:"shared_data,omitempty"` + ConfigHash string `json:"config_hash,omitempty"` + JoiningNode string `json:"joining_node,omitempty"` // The node name that is joining + // CA distribution for per-node certificate generation + CACert string `json:"ca_cert,omitempty"` // PEM-encoded CA certificate + CAKey string `json:"ca_key,omitempty"` // PEM-encoded CA private key + // Predastore config distribution for multi-node clusters + PredastoreConfig string `json:"predastore_config,omitempty"` // Full predastore.toml content +} + +type NodeHealthResponse struct { + Node string `json:"node"` + Status string `json:"status"` + ConfigHash string `json:"config_hash"` + Epoch uint64 `json:"epoch"` + Uptime int64 `json:"uptime"` + Services []string `json:"services"` + ServiceHealth map[string]string `json:"service_health,omitempty"` +} diff --git a/hive/types/ebs.go b/hive/types/ebs.go new file mode 100644 index 000000000..34dba4fa2 --- /dev/null +++ b/hive/types/ebs.go @@ -0,0 +1,72 @@ +package types + +import "sync" + +type EBSRequests struct { + Requests []EBSRequest `mapstructure:"ebs_requests"` + Mu sync.Mutex `json:"-"` +} + +type EBSRequest struct { + Name string + VolType string + Boot bool + EFI bool + CloudInit bool + DeleteOnTermination bool + NBDURI string // NBD URI - socket path (nbd:unix:/path.sock) or TCP (nbd://host:port) + DeviceName string // AWS API device name (e.g. /dev/sdf) for hot-plugged volumes +} + +// 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 + Mounted bool + Error string +} + +type EBSUnMountResponse struct { + Volume string + Mounted bool + Error string +} + +type EBSSyncRequest struct { + Volume string +} + +type EBSSyncResponse struct { + Volume string + Synced bool + Error string +} + +type EBSDeleteRequest struct { + Volume string +} + +type EBSDeleteResponse struct { + Volume string + Success bool + Error string +} + +type EBSSnapshotRequest struct { + Volume string + SnapshotID string +} + +type EBSSnapshotResponse struct { + SnapshotID string + Success bool + Error string +} diff --git a/hive/types/node.go b/hive/types/node.go new file mode 100644 index 000000000..efd2fe86e --- /dev/null +++ b/hive/types/node.go @@ -0,0 +1,48 @@ +package types + +// NodeDiscoverResponse is the response for node discovery requests. +type NodeDiscoverResponse struct { + Node string `json:"node"` +} + +// NodeStatusResponse is returned by the hive.node.status NATS topic (fan-out). +type NodeStatusResponse struct { + Node string `json:"node"` + Status string `json:"status"` + Host string `json:"host"` + Region string `json:"region"` + AZ string `json:"az"` + Uptime int64 `json:"uptime"` + Services []string `json:"services"` + TotalVCPU int `json:"total_vcpu"` + TotalMemGB float64 `json:"total_mem_gb"` + AllocVCPU int `json:"alloc_vcpu"` + AllocMemGB float64 `json:"alloc_mem_gb"` + VMCount int `json:"vm_count"` + InstanceTypes []InstanceTypeCap `json:"instance_types"` +} + +// InstanceTypeCap describes available capacity for one instance type on a node. +type InstanceTypeCap struct { + Name string `json:"name"` + VCPU int `json:"vcpu"` + MemoryGB float64 `json:"memory_gb"` + Available int `json:"available"` +} + +// VMInfo describes a single VM for the cluster stats CLI. +type VMInfo struct { + InstanceID string `json:"instance_id"` + Status string `json:"status"` + InstanceType string `json:"instance_type"` + VCPU int `json:"vcpu"` + MemoryGB float64 `json:"memory_gb"` + LaunchTime int64 `json:"launch_time"` +} + +// NodeVMsResponse is returned by the hive.node.vms NATS topic (fan-out). +type NodeVMsResponse struct { + Node string `json:"node"` + Host string `json:"host"` + VMs []VMInfo `json:"vms"` +}