56fcf8b399
orca init transforms from a bare mkdir into a full single-node cluster bootstrap. After `orca init`, `orca doctor` passes with zero FAILs on the bootstrap checks (CA, cert, db, localhost node). Changes: - migration 0006: nodes.kind + nodes.os nullable columns (REQ-049) - model.Node: Kind + OS fields + NodeKind constants (localhost|linux|proxmox) - NodeRepo: extended Insert/Get/List/Watch/scanNode for kind/os columns (NULL -> "" mapping); added GetByName + UpdateLastSeenAndOS helpers - internal/cli/osdetect.go: detectOS() from /etc/os-release ID= field (D-032); fallback to /usr/lib/os-release then "linux" - internal/cli/init.go: full bootstrap sequence (REQ-047, REQ-048): 1. MkdirAll namespace dir 2. store.Open (runs migrations 0001..0006) 3. security.CAInit (idempotent fast-path) 4. server cert gen if absent (D-036: skip if present) 5. detectOS from /etc/os-release 6. localhost node upsert (insert if new, refresh last_seen+os if exists) Idempotent re-run: no duplicate node, no cert regen, id/joined_at preserved - --json output: full bootstrap summary (namespace, db, ca_fp, cert_fp, os, node_id, steps array) - tests: init idempotency, osdetect parsing (ubuntu/debian/alpine/pve), kind/os round-trip, NULL->"" mapping, GetByName, UpdateLastSeenAndOS E2E smoke test: orca init -> 5 PASS / 0 WARN / 1 FAIL (network=daemon not running, expected); orca node list shows localhost node (os=ubuntu). ---ci--- project: orca phase: 1 milestone: v0.6 status: execute ---/ci---
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
type NodeState string
|
|
|
|
const (
|
|
NodeStatePending NodeState = "pending"
|
|
NodeStateReady NodeState = "ready"
|
|
NodeStateLeft NodeState = "left"
|
|
)
|
|
|
|
// NodeKind classifies a node by how it joined the cluster.
|
|
type NodeKind string
|
|
|
|
const (
|
|
// NodeKindLocalhost is the auto-registered local node from `orca init`.
|
|
NodeKindLocalhost NodeKind = "localhost"
|
|
// NodeKindLinux is a generic Linux node (ubuntu/debian/alpine) joined
|
|
// without a specific type. Reserved for future SSH-join flows.
|
|
NodeKindLinux NodeKind = "linux"
|
|
// NodeKindProxmox is a Proxmox VE 8/9 host joined via SSH bootstrap.
|
|
NodeKindProxmox NodeKind = "proxmox"
|
|
)
|
|
|
|
type Node struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Address string `json:"address"`
|
|
State NodeState `json:"state"`
|
|
JoinedAt time.Time `json:"joined_at"`
|
|
LastSeen time.Time `json:"last_seen"`
|
|
Metadata map[string]string `json:"metadata,omitempty"`
|
|
// Kind classifies the node: localhost | linux | proxmox (REQ-049).
|
|
// Empty string for rows created before migration 0006.
|
|
Kind string `json:"kind,omitempty"`
|
|
// OS is the auto-detected OS identifier from /etc/os-release ID=
|
|
// (ubuntu|debian|alpine|pve|linux). Empty for pre-0006 rows.
|
|
OS string `json:"os,omitempty"`
|
|
}
|