diff --git a/CHANGELOG.md b/CHANGELOG.md index e4a8710..cb49373 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ publish a tag that has no section here. ## [Unreleased] ### Added +- Network page for large sites: a problems strip (offline rack controllers and the VLANs left + without DHCP/PXE, provisioning VLANs without it, subnets over 80%, IPAM errors), filters by fabric, + purpose and rack controller, a search that shows a machine's path (interface, address, VLAN, + rack controller, region), and a VLAN x rack-controller matrix, the default once a site is large. + The topology groups machines more coarsely when boxes would not fit and scrolls instead of + shrinking; the overview shows one row per fabric on a large site. Filters can be put on the URL + (`?fabric=…&view=matrix&q=…`) to share a view. - Root rotation without re-joining (`rollcall ca rotate prepare | switch | retire`, status without an argument). The trust bundle (all current roots, `/ca-bundle.pem`) reaches rack controllers signed by the active root and is installed by their root unit only when that signature verifies; diff --git a/cmd/rollcall/web/app.js b/cmd/rollcall/web/app.js index 66720d9..f8ce794 100644 --- a/cmd/rollcall/web/app.js +++ b/cmd/rollcall/web/app.js @@ -175,7 +175,8 @@ function pageOverview() { const subRows = S.subnets.filter(s => s.size).sort((a, b) => b.used / b.size - a.used / a.size).slice(0, 6) .map(s => [`${esc(s.cidr)}`, s.used, `${s.purpose} · ${s.used} of ${s.size} addresses`, '', s.size, `${s.used}/${s.size}`]); const maxPct = S.subnets.filter(s => s.size).map(s => [s, s.used / s.size]).sort((a, b) => b[1] - a[1])[0]; - const network = `
${topoSVG({ compact: true })}
+ // a drawing for a small site; one row per fabric for a large one (netview.js) + const network = `${nvLarge() ? nvFabricSummaryHTML() : `
${topoSVG({ compact: true })}
`}
ADDRESSES IN USE
${hbars(subRows)}
${kv([['Subnets', `${S.subnets.length} (${S.subnets.filter(s => s.family === 6).length} IPv6)`], ['VLANs with DHCP', String(new Set(S.subnets.filter(s => s.dhcp).map(s => s.vlan_id)).size)], @@ -226,6 +227,7 @@ function pageOverview() { } function wireOverview() { wireTopo(); + wireFabricSummary(); $$('[data-go]').forEach(el => { if (el.closest('.topo') && !el.dataset.go.includes('/')) return; el.onclick = ev => { ev.preventDefault(); const [p, st] = el.dataset.go.split('/'); S.states.clear(); S.tagf.clear(); if (st) S.states.add(st); nav(p); }; }); $$('[data-tag]').forEach(el => el.onclick = () => { S.states.clear(); S.tagf.clear(); S.tagf.add(el.dataset.tag); nav('machines'); }); } @@ -742,10 +744,13 @@ function wireNetPlan(id) { // ---------------------------------------------------------------- network page function pageNetwork() { const regionVer = (S.controllers.find(c => c.kind === 'embedded') || {}).version; - const ctl = table(['Controller', 'Kind', 'State', 'URL', 'Machines', 'Version', 'Last seen', 'Interfaces', ''], S.controllers.map(c => [`${esc(c.name)}`, esc(c.kind), c.online ? 'online' : 'offline', `${esc(c.url)}`, c.machines, + const f = nvFilter(), large = nvLarge(), view = NV.view || (large ? 'matrix' : 'topology'); + const subs = S.subnets.filter(f.subnet); + const ctls = S.controllers.filter(c => f.rack(c.name) && (!f.active || NV.rack || topoModel(f).racks.some(r => r.c.name === c.name && r.at.length))); + const ctl = table(['Controller', 'Kind', 'State', 'URL', 'Machines', 'Version', 'Last seen', 'Interfaces', ''], ctls.map(c => [`${esc(c.name)}`, esc(c.kind), c.online ? 'online' : 'offline', `${esc(c.url)}`, c.machines, `${esc(c.version || '—')}`, `${ago(c.last_seen)}`, `${esc((c.interfaces || []).map(i => i.name + ' ' + (i.addrs || []).join(',')).join(' · '))}`, `${c.kind === 'remote' ? ` ` : ''}`])); - const sub = table(['Subnet', 'Purpose', 'Fabric / VLAN', 'DHCP', 'Gateway', 'DNS', 'Usage', 'Ranges', ''], S.subnets.map(s => { + const sub = table(['Subnet', 'Purpose', 'Fabric / VLAN', 'DHCP', 'Gateway', 'DNS', 'Usage', 'Ranges', ''], subs.map(s => { const pct = s.size ? Math.round(s.used * 100 / s.size) : 0; const sizeTxt = s.size ? s.size : '∞'; const ranges = (s.ranges || []).map(r => `${esc(r.kind)} ${esc(r.start)}–${esc(r.end.split('.').pop())} ×`).join(' '); @@ -757,10 +762,15 @@ function pageNetwork() { const lay = table(['Layout', 'Machines', 'Interfaces', 'Comment', ''], S.layouts.map(l => [`${esc(l.name)}`, l.machines || 0, `${esc(layoutSummary(l))}`, esc(l.comment || ''), ` `])); return `

Network

fabrics, VLANs and subnets (MAAS-style); rack controllers serve DHCP/PXE on their VLANs
-

Topology

${topoSVG()}
-
VLAN with DHCP/PXEVLANstorage / IBrack ↔ region (mTLS)rack offlinerack serves/sits on the VLANmachine addressclick a bus for its addresses, a machine for its page
-

Rack controllers

${ctl}

Add one next to a segment: rollcall controller join-code -name NAME -addr REGION:443 here, then on that host ./rollcall rack join CODE -url http://ITS-ADDRESS and sh install-rack.sh. It talks to the region over mutual TLS.

-

Subnets

${sub}
+ ${nvToolbarHTML(large)} + ${nvIssuesHTML()} + ${nvPathHTML()} + ${view === 'matrix' + ? `

VLANs × rack controllers${f.active ? ' (filtered)' : ''}

${nvMatrixHTML(f)}
` + : `

Topology${f.active ? ' (filtered)' : ''}

${topoSVG({ filter: f })}
+
VLAN with DHCP/PXEVLANstorage / IBrack ↔ region (mTLS)rack offlinerack serves/sits on the VLANmachine addressclick a bus for its addresses, a machine for its page${large && !f.active ? '; filter by fabric or rack for a readable part of a large site' : ''}
`} +

Rack controllers${ctls.length < S.controllers.length ? ` (${ctls.length} of ${S.controllers.length})` : ''}

${ctl}

Add one next to a segment: rollcall controller join-code -name NAME -addr REGION:443 here, then on that host ./rollcall rack join CODE -url http://ITS-ADDRESS and sh install-rack.sh. It talks to the region over mutual TLS.

+

Subnets${subs.length < S.subnets.length ? ` (${subs.length} of ${S.subnets.length})` : ''}

${sub}

Interface layouts

${lay}

A layout applies to a machine directly (More → Network layout…) or through a tag (Tags → layout). Without one, the boot NIC gets an address on its subnet.

`; } const layoutExample = JSON.stringify({ interfaces: [ @@ -800,6 +810,7 @@ async function editLayout(l) { } function wireNetwork() { wireTopo(); + wireNetView(); let dl = $('#dl-fabrics'); if (!dl) { dl = document.createElement('datalist'); dl.id = 'dl-fabrics'; document.body.appendChild(dl); } dl.innerHTML = S.fabrics.map(f => ``; + const fabrics = [...new Set(S.subnets.map(s => s.fabric).filter(Boolean))].sort(); + const purposes = [...new Set(S.subnets.map(s => s.purpose).filter(Boolean))].sort(); + return `
+ + + + + ${NV.fabric || NV.purpose || NV.rack || NV.q ? '' : ''} + +
`; +} + +function nvLarge() { return S.subnets.length > 12 || S.machines.length > 60 || S.controllers.length > 4; } + +function wireNetView() { + const again = () => { nvSave(); render(); }; + const q = $('#nv-q'); + if (q) { + q.oninput = () => { NV.q = q.value; clearTimeout(q._t); q._t = setTimeout(() => { render(); const n = $('#nv-q'); if (n) { n.focus(); n.setSelectionRange(n.value.length, n.value.length); } }, 250); }; + } + for (const k of ['fabric', 'purpose', 'rack']) { const el = $('#nv-' + k); if (el) el.onchange = () => { NV[k] = el.value; again(); }; } + const c = $('#nv-clear'); if (c) c.onclick = () => { Object.assign(NV, { fabric: '', purpose: '', rack: '', q: '' }); again(); }; + $$('[data-nvview]').forEach(b => b.onclick = () => { NV.view = b.dataset.nvview; again(); }); + $$('[data-nvrack]').forEach(d => d.onclick = () => { NV.rack = d.dataset.nvrack; again(); }); + const more = $('#nv-more'); if (more) more.onclick = ev => { ev.preventDefault(); NV.allIssues = !NV.allIssues; render(); }; +} + +// nvFabricSummaryHTML: the overview's network card on a large site, one row +// per fabric instead of a drawing; a row opens the network page filtered to it. +function nvFabricSummaryHTML() { + const { segs, racks, ms } = topoModel(); + const issues = nvIssues(); + const fabs = [...new Set(segs.map(g => g.fabric || ''))].sort(); + const rows = fabs.map(fab => { + const idx = segs.map((g, i) => (g.fabric || '') === fab ? i : -1).filter(i => i >= 0); + const rk = racks.filter(r => r.at.some(i => idx.includes(i))); + const down = rk.filter(r => !r.c.online).length; + const n = ms.filter(x => x.at.some(i => idx.includes(i))).length; + const subs = idx.flatMap(i => segs[i].subnets); + const full = subs.filter(s => s.size).map(s => [s, s.used / s.size]).sort((a, b) => b[1] - a[1])[0]; + const cidrs = new Set(subs.map(s => s.cidr)), names = new Set(rk.map(r => r.c.name)); + const probs = issues.filter(i => (i.cidr && cidrs.has(i.cidr)) || (i.rack && names.has(i.rack))).length; + const pct = full ? Math.round(full[1] * 100) : 0; + return `${esc(fab || 'no fabric')}${idx.length}${idx.filter(i => segs[i].dhcp).length} + ${rk.length - down}/${rk.length}${down ? ` ${down} offline` : ''}${n} + ${full ? `${esc(full[0].cidr)} ${pct}%` : '—'} + ${probs ? `${probs}` : 'none'}`; + }); + return `${rows.join('')}
FabricVLANswith DHCPRack controllersMachinesFullest subnetProblems
`; +} +function wireFabricSummary() { + $$('[data-nvfabric]').forEach(r => r.onclick = () => { NV.fabric = r.dataset.nvfabric; nvSave(); nav('network'); }); +} diff --git a/cmd/rollcall/web/style.css b/cmd/rollcall/web/style.css index c668d5e..bd6cced 100644 --- a/cmd/rollcall/web/style.css +++ b/cmd/rollcall/web/style.css @@ -33,7 +33,7 @@ a { color: var(--accent); } .side a:hover { background: var(--side-act); } .side a.active { background: var(--side-act); color: #fff; } .side .count { font-size: 11px; opacity: .8; } .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px; font-size: 11px; } -main { padding: 18px 22px; max-width: 1500px; width: 100%; } +main { padding: 18px 22px; max-width: 1500px; width: 100%; min-width: 0; } .page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; } .page-head h1 { font-size: 18px; margin: 0; } .page-head .sub { color: var(--muted); } .page-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; } @@ -176,3 +176,31 @@ svg.topo .mach.group.ok rect:first-child { stroke: var(--ok); } svg.topo .mach.g .statebar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--pill); margin: 4px 0 10px; } .statebar span { height: 100%; } .statebar .ok { background: var(--ok); } .statebar .warn { background: var(--warn); } .statebar .bad { background: var(--danger); } .statebar .idle { background: var(--line2); } @media (max-width: 1100px) { .ov > .card, .ov > .card.w6, .ov > .card.w8 { grid-column: 1 / -1; } } + +/* network page for large sites (netview.js) */ +.nv-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; } +.nv-bar #nv-q { width: 240px; } .nv-bar .right { margin-left: auto; } +.seg-btns { display: inline-flex; } .seg-btns .btn { border-radius: 0; } .seg-btns .btn:first-child { border-radius: 6px 0 0 6px; } .seg-btns .btn:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; } +.seg-btns .btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); } +.nv-issues { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; margin-bottom: 12px; } +.nv-issues.ok { color: var(--muted); padding: 9px 12px; } +.nv-issue { padding: 4px 0; } .nv-issue[data-ips], .nv-issue[data-nvrack] { cursor: pointer; } .nv-issue[data-ips]:hover, .nv-issue[data-nvrack]:hover { text-decoration: underline; } +.nv-issue.bad { color: var(--danger); } .nv-issue.warn { color: var(--warn); } +.nv-issues > a { display: inline-block; margin: 2px 0 4px; font-size: 12px; } +table.nv-matrix { min-width: 0; } .nv-matrix td, .nv-matrix th { padding: 5px 8px; } +.nv-matrix th.nv-rackh { height: 92px; vertical-align: bottom; padding: 4px 2px; width: 26px; min-width: 26px; text-align: center; } +.nv-matrix th.nv-rackh span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-family: var(--mono); text-transform: none; letter-spacing: 0; font-size: 11.5px; } +.nv-matrix th.nv-rackh.down span { color: var(--danger); } +.nv-matrix td.nv-cell { text-align: center; padding: 5px 2px; font-size: 14px; color: var(--muted); border-left: 1px solid var(--line); } +.nv-matrix td.nv-cell.serve { color: var(--ok); } .nv-matrix td.nv-cell.second { opacity: .65; } .nv-matrix td.nv-cell.down { color: var(--danger); opacity: 1; } +.nv-matrix tr.nv-fab td { background: var(--hover); font-weight: 600; font-size: 12px; padding: 5px 8px; } +.nv-matrix tr.nv-row { cursor: pointer; } .nv-matrix tr.nv-row:hover td { background: var(--hover); } +.nv-matrix tr.nv-row.hl td { background: var(--sel); } +.nv-matrix td.num, .nv-matrix th.num { text-align: right; } +.nv-states { display: flex; height: 4px; border-radius: 2px; overflow: hidden; margin-top: 2px; min-width: 60px; background: var(--pill); } +.nv-states i { display: block; } .nv-states i.ok { background: var(--ok); } .nv-states i.warn { background: var(--warn); } .nv-states i.bad { background: var(--danger); } .nv-states i.idle { background: var(--line2); } +.nv-matrix .bar { min-width: 70px; } +.bar.warn > span { background: var(--warn); } .bar.bad > span { background: var(--danger); } +.legend b.g { color: var(--ok); font-weight: 400; } .legend b.r { color: var(--danger); font-weight: 400; } +.nv-pathcard { margin-bottom: 12px; } .nv-path { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 4px 0; } +.nv-path .arr { color: var(--muted); } diff --git a/cmd/rollcall/web/topo.js b/cmd/rollcall/web/topo.js index 1e9ebad..987262d 100644 --- a/cmd/rollcall/web/topo.js +++ b/cmd/rollcall/web/topo.js @@ -30,10 +30,12 @@ function inCidr(ip, cidr) { } // ---------------------------------------------------------------- model -// topoModel groups subnets into segments (one per VLAN), attaches racks and machines. -function topoModel() { +// topoModel groups subnets into segments (one per VLAN), attaches racks and +// machines; f (netview.js nvFilter) keeps part of the site. +function topoModel(f = {}) { + const keepSub = f.subnet || (() => true), keepRack = f.rack || (() => true), keepM = f.machine || (() => true); const segs = [], byVlan = {}; - for (const s of S.subnets) { + for (const s of S.subnets.filter(keepSub)) { const key = s.vlan_id ? 'v' + s.vlan_id : 'c' + s.cidr; if (!byVlan[key]) { byVlan[key] = { key, fabric: s.fabric, vid: s.vid, mtu: s.mtu, subnets: [], racks: new Set(), dhcp: false, purpose: s.purpose }; segs.push(byVlan[key]); } const g = byVlan[key]; @@ -44,7 +46,7 @@ function topoModel() { segs.sort((a, b) => (b.dhcp - a.dhcp) || String(a.fabric).localeCompare(String(b.fabric)) || a.vid - b.vid); const segOf = ip => segs.findIndex(g => g.subnets.some(s => inCidr(ip, s.cidr))); // rack controllers: the segments they serve DHCP on, plus those their interfaces sit on - const racks = S.controllers.map(c => { + const racks = S.controllers.filter(c => keepRack(c.name)).map(c => { const at = new Set(); segs.forEach((g, i) => { if (g.racks.has(c.name)) at.add(i); }); for (const itf of (c.interfaces || [])) for (const a of (itf.addrs || [])) { const i = segOf(a); if (i >= 0) at.add(i); } @@ -53,7 +55,7 @@ function topoModel() { // machines: every address Rollcall knows for them const ipsBy = {}; for (const x of S.ips) if (x.machine_id) (ipsBy[x.machine_id] = ipsBy[x.machine_id] || []).push(x.ip); - const ms = S.machines.map(m => { + const ms = S.machines.filter(keepM).map(m => { const at = new Set(); for (const ip of [...(ipsBy[m.id] || []), m.mgmt_ip, m.ib_ip]) { if (!ip) continue; const i = segOf(ip); if (i >= 0) at.add(i); } return { m, at: [...at].sort((a, b) => a - b) }; @@ -75,22 +77,36 @@ const stateClass = st => /failed/.test(st) ? 'bad' : /deploying|releasing|recomm // topoSVG({compact}) -> svg markup. compact: overview card (fewer labels, collapsed groups). function topoSVG(opt = {}) { - const { segs, racks, ms } = topoModel(); - if (!segs.length && !racks.length) return '
No subnets or rack controllers yet.
'; + const model = topoModel(opt.filter), { segs } = model; + let { racks, ms } = model; + const filtered = !!(opt.filter && opt.filter.active); + if (filtered) ms = ms.filter(x => x.at.length); // machines elsewhere are not part of this view + if (!segs.length && !racks.length) return '
No subnets or rack controllers match.
'; const compact = !!opt.compact; const BW = compact ? 112 : 156, BH = compact ? 40 : 50, GAP = compact ? 12 : 16, M = 24; const collapseAt = compact ? 4 : 8; + const maxItems = compact ? 10 : 28; // more boxes than this and the drawing stops being readable - // machine items: one box per machine, or one per group of machines with the same wiring - const groups = {}; - for (const x of ms) { const k = (x.m.rack_controller || '') + '|' + x.at.join(','); (groups[k] = groups[k] || []).push(x); } + // machine items: one box per machine, or one per group of machines with the + // same wiring; when that still makes too many, coarser groups: by rack and + // first VLAN, then by rack alone (a group is wired to every VLAN of its members) const rackIdx = name => { const i = racks.findIndex(r => r.c.name === name); return i < 0 ? 999 : i; }; - let items = []; - for (const [k, xs] of Object.entries(groups)) { - const rack = k.split('|')[0]; - if (xs.length >= collapseAt) items.push({ group: xs, at: xs[0].at, rack }); - else for (const x of xs) items.push({ m: x.m, at: x.at, rack }); - } + const build = (key, at) => { + const groups = {}; + for (const x of ms) { const k = (x.m.rack_controller || '') + '|' + key(x); (groups[k] = groups[k] || []).push(x); } + const out = []; + for (const [k, xs] of Object.entries(groups)) { + const rack = k.split('|')[0]; + if (xs.length >= collapseAt || at) out.push({ group: xs, at: [...new Set(xs.flatMap(x => x.at))].sort((a, b) => a - b), rack }); + else for (const x of xs) out.push({ m: x.m, at: x.at, rack }); + } + return out; + }; + let items = build(x => x.at.join(',')); + if (items.length > maxItems) items = build(x => String(x.at[0] ?? ''), true); + if (items.length > maxItems) items = build(() => '', true); + for (const it of items) if (it.group && it.group.length === 1) { it.m = it.group[0].m; delete it.group; } + if (filtered) racks = racks.filter(r => r.at.length || items.some(it => it.rack === r.c.name)); items.sort((a, b) => rackIdx(a.rack) - rackIdx(b.rack) || (a.at[0] ?? 99) - (b.at[0] ?? 99) || String(a.m ? nameOf(a.m) : '').localeCompare(String(b.m ? nameOf(b.m) : ''))); const minW = compact ? 640 : 980; @@ -119,7 +135,8 @@ function topoSVG(opt = {}) { if (hasIPAM) W = Math.max(W, ix + iw / 2 + M); const o = []; - o.push(``); + // the overview card shrinks it to fit; the network page scrolls instead (text stays readable) + o.push(``); // segments (buses) with their labels in the left gutter segs.forEach((g, i) => { const y = segY[i];