Files
ilkerandClaude Opus 5.5 090719fc74
ci / derle (push) Successful in 30s
hpcod: clusters across the nodes of a Proxmox cluster
Discovery already saw every node of a Proxmox cluster and placement could
put a VM on any of them, but the template, the snippets and a simple SDN
zone only worked on PVE_NODE, so a cluster could land where it could not
be built.

- Setup asks which nodes clusters may use (PVE_NODES; a multi-select in
  the TUI when Proxmox has more than one). Discovery offers only those.
- Heads are placed on PVE_NODE only (head_node), where the template is, so
  no shared storage is needed; diskless compute nodes spread.
- PVE_SDN_ZONE_TYPE (auto|simple|vxlan): more than one node makes the zone
  vxlan, every node a peer, MTU 1450. A zone of the wrong type is remade
  only while no cluster has a vnet in it. Guest fabric NICs take the
  bridge MTU through virtio (mtu = 1).
- setup keeps nodes and head_node of its own site in sites.yaml, leaving
  the rest of the file as the operator wrote it.
- verify checks the nodes are online and the zone matches.

Run on the simulated Proxmox with the zone forced to vxlan: setup remade
the zone, a two-node selftest passed, both compute NICs came up at 1450,
and a DF ping of 1422 bytes passed between them while 1423 did not. Two
real Proxmox nodes have not been tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 19:51:35 +01:00

62 lines
2.0 KiB
Go

package tui
import (
"strings"
"testing"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/huh"
"github.com/ilkermanap/hpcod/internal/setup"
)
// In a Proxmox cluster the form asks which nodes clusters may use, starts
// from what the site already has, and keeps the heads' node ticked.
func TestNodesAreAskedForInAProxmoxCluster(t *testing.T) {
bound = map[string]*string{}
site := setup.Defaults()
site["PVE_ENDPOINT"], site["PVE_NODE"], site["PVE_NODES"] = "https://192.0.2.10:8006", "pve1", "pve1,pve3"
p := &setup.Probe{Version: "8.4.1", Nodes: []string{"pve1", "pve2", "pve3"},
Storages: []setup.Storage{{ID: "local", Type: "dir", Content: []string{"images", "import", "snippets"}}}}
f := huh.NewForm(proxmoxGroup(site, p)).WithWidth(100).WithHeight(60)
f.Init()
f.Update(tea.WindowSizeMsg{Width: 100, Height: 60})
if v := f.View(); !strings.Contains(v, "Nodes clusters may use") {
t.Fatalf("no node choice in the form:\n%s", v)
}
if nodeChoice == nil || strings.Join(*nodeChoice, ",") != "pve1,pve3" {
t.Fatalf("preselected %v, want pve1,pve3", nodeChoice)
}
*nodeChoice = []string{"pve2", "pve3"}
commit(site)
if site["PVE_NODES"] != "pve2,pve3" {
t.Errorf("PVE_NODES = %q after commit", site["PVE_NODES"])
}
if errs := site.Validate(); !strings.Contains(joinErrs(errs), "PVE_NODES") {
t.Errorf("a choice without the heads' node passed validation: %v", errs)
}
}
func TestOneNodeAsksNothingMore(t *testing.T) {
bound = map[string]*string{}
site := setup.Defaults()
site["PVE_ENDPOINT"], site["PVE_NODE"] = "https://192.0.2.10:8006", "hv01"
p := &setup.Probe{Version: "8.4.1", Nodes: []string{"hv01"}}
f := huh.NewForm(proxmoxGroup(site, p)).WithWidth(100).WithHeight(60)
f.Init()
f.Update(tea.WindowSizeMsg{Width: 100, Height: 60})
if strings.Contains(f.View(), "Nodes clusters may use") || nodeChoice != nil {
t.Error("a single node was offered as a choice")
}
}
func joinErrs(errs []error) string {
var b strings.Builder
for _, e := range errs {
b.WriteString(e.Error() + ";")
}
return b.String()
}