feat: HA-Cluster v1.2.x — Split-Brain, TOTP, Enterprise-FW, Drift-Fix, VIP-Recovery
- keepalived: pg_role='standby' hat Vorrang vor role für BACKUP-Bestimmung - keepalived-master.sh: gecrasht Dienste beim MASTER-Übergang starten (nicht nur reload) - confighash: ip_addresses per Interface-Name hashen statt per FK (Cross-Node-Drift-Fix) - TOTP/2FA: RFC 6238 — Setup-Flow, QR-Code, Admin-Disable; two-step Login - Firewall-UI: Enterprise-Design — auto-Beschreibung, icon-only Actions, zero-hit Indikator - fe80-Filter: Link-local IPv6 aus NTP/DNS Listen-Dropdowns entfernen - VIP-Dashboard, Dual-Path VRRP, GW-Tracking (Migrations 0033/0034) - Forward Proxy + DNS erweiterte Einstellungen (Migrations 0031/0032) - unbound-control: edgeguard in unbound-Gruppe via postinst Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,7 @@ type hashTable struct {
|
||||
SkipUpdatedAt bool // setze true wenn updated_at semantisch relevant ist
|
||||
MigrationDefault bool // Tabelle hat migrations-erzeugte Default-Rows (firewall_zones, ntp_pools…)
|
||||
// → zählt nicht als "user hat config" bei der Empty-DB-Erkennung
|
||||
CustomSQL string // wenn gesetzt: direkt als Hash-Query verwenden (überschreibt hashSQL)
|
||||
}
|
||||
|
||||
// hashSpec ist die Reihenfolge-stabile Liste. NEUE Tabellen hier
|
||||
@@ -70,9 +71,33 @@ var hashSpec = []hashTable{
|
||||
|
||||
{Name: "ntp_pools", MigrationDefault: true},
|
||||
|
||||
// network_interfaces, ip_addresses, static_routes, dns_settings, ntp_settings
|
||||
// sind node-spezifisch (jeder Node hat eigene IPs/Routes/Listen-Adressen)
|
||||
// und fließen NICHT in den Drift-Hash ein.
|
||||
// network_interfaces + ip_addresses werden seit 0030 repliziert —
|
||||
// VLAN/Bridge/Bond-Definitionen und Gateway-IPs müssen auf dem Secondary
|
||||
// für Failover bereitstehen. Ethernet-IPs werden im Secondary-Renderer
|
||||
// herausgefiltert (eth0 = cloud-init / Keepalived).
|
||||
//
|
||||
// ip_addresses.interface_id ist ein node-lokaler Autoincrement-PK, der
|
||||
// zwischen zwei unabhängigen DBs divergiert (utm-1: eth0=6, utm-2: eth0=1).
|
||||
// Wir hashen daher semantisch: address + prefix + flags + interface_name
|
||||
// statt interface_id — sonst False-Positive-Drift auf logisch identischen Nodes.
|
||||
{Name: "network_interfaces"},
|
||||
{Name: "ip_addresses", CustomSQL: `
|
||||
SELECT COALESCE(md5(string_agg(rh, '|' ORDER BY rh)), '')
|
||||
FROM (
|
||||
SELECT md5(jsonb_build_object(
|
||||
'address', ia.address,
|
||||
'prefix', ia.prefix,
|
||||
'is_vip', ia.is_vip,
|
||||
'active', ia.active,
|
||||
'vip_priority', ia.vip_priority,
|
||||
'description', ia.description,
|
||||
'iface', ni.name
|
||||
)::text) AS rh
|
||||
FROM ip_addresses ia
|
||||
JOIN network_interfaces ni ON ia.interface_id = ni.id
|
||||
) sub`},
|
||||
|
||||
// static_routes, dns_settings, ntp_settings bleiben node-spezifisch.
|
||||
}
|
||||
|
||||
// hashSQL rendert die SHA-Input-SQL für eine Tabelle.
|
||||
@@ -112,7 +137,11 @@ func ComputeConfigHash(ctx context.Context, pool *pgxpool.Pool) (string, error)
|
||||
hasUserConfig := false
|
||||
for _, t := range hashSpec {
|
||||
var s string
|
||||
if err := pool.QueryRow(ctx, hashSQL(t)).Scan(&s); err != nil {
|
||||
sql := t.CustomSQL
|
||||
if sql == "" {
|
||||
sql = hashSQL(t)
|
||||
}
|
||||
if err := pool.QueryRow(ctx, sql).Scan(&s); err != nil {
|
||||
// Migration fehlt o.ä. → leeren string nehmen, weiter.
|
||||
s = ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user