platform/cmd/webui: add a scriptable test-scenario engine, load scenarios from blackbox USB, GPU status detail inventory fallback
Investigating the CG480-S6053 reboot needed a way to run an ad-hoc load
(nvbandwidth across a specific GPU set) while sampling IPMI/nvidia-smi
telemetry in the background — without hardcoding a one-off test into the
SAT pack code for a single investigation.
- audit/internal/platform/scenario.go: ScenarioSpec/ScenarioJob (JSON,
no new dependency) + System.RunScenario. "command" jobs run sequential
or parallel (per-job "parallel" flag); "sampler" jobs run concurrently
in the background on their own interval until every command job
finishes or the scenario's timeout elapses. "{{gpus}}" in a command's
cmd is substituted from that job's gpu_indices. Command jobs are wired
through the same satJobBoundaryHook/satSyncBracketHook seams the SAT
job runner uses, so a scenario run gets the same durability treatment
(evidence that a risky command started/finished reaches blackbox before
a possible crash, not just whatever streamed to the RAM-backed export
dir).
- export.go: ReadScenarioFromRemovableMedia mounts each removable target
looking for scenarios/<name>.json — an air-gapped engineer can author a
scenario elsewhere, drop it under scenarios/ on the same USB stick
already plugged in for blackbox, and run it with no network path onto
the host.
- cmd/bee: new `bee run <file.json|name>` (bare name = looked up on
removable media); `bee scenario run <arg>` kept as a longer alias.
- scenarios/nvbandwidth-all-gpu-power-watch.json: the scenario that
reproduced the actual reboot (full nvbandwidth across all GPUs, which
crashed, vs. clean per-socket passes), with IPMI sensor + GPU power/temp
sampling for a power-delivery correlation check.
Also: webui/page_topo.go — the /topo page's component-status-detail modal
(GET /api/component-detail/{type}) showed "No status data recorded yet"
for any component type ComponentStatusDB has no history for yet (e.g. GPU
before a SAT run this boot), even though the topology card for the same
component already showed "N OK" from the audit inventory snapshot.
inventoryFallbackRecords now synthesizes records from that same inventory
snapshot when StatusDB is empty, using the same device classifiers
(isGPUDeviceClass etc.) and severity mapping (classifyTopoSeverity) the
topology card itself uses, so the two views never disagree.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
49979c4da4
commit
20cd317c87
@@ -151,3 +151,55 @@ func (s *System) ExportFileToTarget(src string, target RemovableTarget) (dst str
|
||||
|
||||
return dst, nil
|
||||
}
|
||||
|
||||
// mountRemovableTargetReadOnly mounts target for reading if it isn't
|
||||
// already mounted (reusing its existing mountpoint otherwise), returning
|
||||
// whether this call did the mounting so the caller knows whether to
|
||||
// unmount afterward.
|
||||
func mountRemovableTargetReadOnly(target RemovableTarget) (mountpoint string, mountedHere bool, err error) {
|
||||
if mp := strings.TrimSpace(target.Mountpoint); mp != "" {
|
||||
return mp, false, nil
|
||||
}
|
||||
mountpoint = filepath.Join("/tmp", "bee-scenario-"+filepath.Base(target.Device))
|
||||
if err := os.MkdirAll(mountpoint, 0755); err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
if raw, err := exportExecCommand("mount", target.Device, mountpoint).CombinedOutput(); err != nil {
|
||||
_ = os.Remove(mountpoint)
|
||||
return "", false, formatMountTargetError(target, string(raw), err)
|
||||
}
|
||||
return mountpoint, true, nil
|
||||
}
|
||||
|
||||
// ReadScenarioFromRemovableMedia mounts each removable target in turn
|
||||
// (unmounting again afterward if it mounted it itself), looking for
|
||||
// scenarios/<name>.json, and returns the contents of the first one found.
|
||||
// Lets an air-gapped engineer author a scenario JSON file on another
|
||||
// machine, drop it under scenarios/ on the same flash drive already
|
||||
// plugged in for blackbox, and run it on the host with no network path
|
||||
// required — see RunScenario/ParseScenarioJSON.
|
||||
func (s *System) ReadScenarioFromRemovableMedia(name string) ([]byte, error) {
|
||||
name = strings.TrimSpace(name)
|
||||
if name == "" {
|
||||
return nil, fmt.Errorf("scenario name is required")
|
||||
}
|
||||
targets, err := s.ListRemovableTargets()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, target := range targets {
|
||||
mountpoint, mountedHere, mountErr := mountRemovableTargetReadOnly(target)
|
||||
if mountErr != nil {
|
||||
continue
|
||||
}
|
||||
data, readErr := os.ReadFile(filepath.Join(mountpoint, "scenarios", name+".json"))
|
||||
if mountedHere {
|
||||
_, _ = exportExecCommand("umount", mountpoint).CombinedOutput()
|
||||
_ = os.Remove(mountpoint)
|
||||
}
|
||||
if readErr == nil {
|
||||
return data, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("scenarios/%s.json not found on any removable media", name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user