BEE-SP v14.08 bundles from Dell R7715 were captured while bee-audit.service was still running (stuck in ipmitool sensor), so bee-audit.json was missing and import failed with "easy-bee snapshot not found". Rebuild board, CPU, DIMM, GPU and NIC inventory from export/gpu/nvidia-bug-report.txt, add an Incomplete Audit warning, and name the audit service state in the error when no fallback source exists. ADL-076. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
3.5 KiB
Go
99 lines
3.5 KiB
Go
package easy_bee
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"git.mchus.pro/mchus/logpile/internal/models"
|
|
"git.mchus.pro/mchus/logpile/internal/parser"
|
|
"git.mchus.pro/mchus/logpile/internal/parser/vendors/nvidia_bug_report"
|
|
)
|
|
|
|
// parseWithoutSnapshot handles bundles captured before bee-audit finished
|
|
// writing bee-audit.json. The NVIDIA bug report bundled under export/gpu/
|
|
// carries dmidecode, lspci and nvidia-smi output for the whole host, so it
|
|
// is used to rebuild a reduced inventory instead of failing the import.
|
|
func parseWithoutSnapshot(files []parser.ExtractedFile, manifest manifestMetadata) (*models.AnalysisResult, error) {
|
|
auditState := beeAuditServiceState(files)
|
|
|
|
report := findNvidiaBugReport(files)
|
|
if report == nil {
|
|
return nil, fmt.Errorf("easy-bee snapshot not found: %s", describeMissingSnapshot(auditState))
|
|
}
|
|
|
|
result, err := (&nvidia_bug_report.Parser{}).Parse([]parser.ExtractedFile{*report})
|
|
if err != nil {
|
|
return nil, fmt.Errorf("easy-bee snapshot not found, fallback to %s failed: %w", report.Path, err)
|
|
}
|
|
if result.Hardware == nil || (result.Hardware.BoardInfo.SerialNumber == "" &&
|
|
len(result.Hardware.CPUs) == 0 &&
|
|
len(result.Hardware.Memory) == 0 &&
|
|
len(result.Hardware.GPUs) == 0) {
|
|
return nil, fmt.Errorf("easy-bee snapshot not found: %s; %s has no inventory", describeMissingSnapshot(auditState), report.Path)
|
|
}
|
|
|
|
result.TargetHost = firstNonEmpty(result.TargetHost, manifest.Host)
|
|
if result.CollectedAt.IsZero() && !manifest.GeneratedAtUTC.IsZero() {
|
|
result.CollectedAt = manifest.GeneratedAtUTC.UTC()
|
|
}
|
|
result.TopologyEvidence = collectTopologyEvidence(files)
|
|
|
|
if pn := chassisProductPartNumber(files, result.Hardware.BoardInfo.ProductName); pn != "" {
|
|
result.Hardware.BoardInfo.PartNumber = pn
|
|
}
|
|
if len(result.FRU) == 0 {
|
|
if boardFRU, ok := buildBoardFRU(result.Hardware.BoardInfo); ok {
|
|
result.FRU = append(result.FRU, boardFRU)
|
|
}
|
|
}
|
|
|
|
result.Events = append(result.Events, models.Event{
|
|
Source: "Bee Audit",
|
|
EventType: "Incomplete Audit",
|
|
Severity: models.SeverityWarning,
|
|
Description: fmt.Sprintf("%s; inventory reconstructed from %s (storage, PSU and sensors unavailable)", describeMissingSnapshot(auditState), pathBase(report.Path)),
|
|
})
|
|
|
|
return result, nil
|
|
}
|
|
|
|
func findNvidiaBugReport(files []parser.ExtractedFile) *parser.ExtractedFile {
|
|
for i := range files {
|
|
name := strings.ToLower(pathBase(files[i].Path))
|
|
if strings.HasPrefix(name, "nvidia-bug-report") &&
|
|
(strings.HasSuffix(name, ".txt") || strings.HasSuffix(name, ".log")) &&
|
|
len(files[i].Content) > 0 {
|
|
return &files[i]
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// beeAuditServiceState returns the systemd "Active:" line of bee-audit.service
|
|
// captured in the bundle, e.g. "activating (start) since ... ; 2min 22s ago".
|
|
func beeAuditServiceState(files []parser.ExtractedFile) string {
|
|
for _, f := range files {
|
|
if !strings.EqualFold(pathBase(f.Path), "bee-audit.service.status.txt") {
|
|
continue
|
|
}
|
|
for _, line := range strings.Split(string(f.Content), "\n") {
|
|
line = strings.TrimSpace(line)
|
|
if state, ok := strings.CutPrefix(line, "Active:"); ok {
|
|
return strings.TrimSpace(state)
|
|
}
|
|
}
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func describeMissingSnapshot(auditState string) string {
|
|
switch {
|
|
case auditState == "":
|
|
return "bee-audit.json is missing from the bundle"
|
|
case strings.HasPrefix(auditState, "activating"):
|
|
return "bee-audit.json is missing: bee-audit.service had not finished when the bundle was captured (" + auditState + ")"
|
|
default:
|
|
return "bee-audit.json is missing (bee-audit.service: " + auditState + ")"
|
|
}
|
|
}
|