feat: adaptive BMC readiness check + ghost NIC dedup fix + empty collection plan-B retry
BMC readiness after power-on (waitForStablePoweredOnHost): - After initial 1m stabilization, poll BMC inventory readiness before collecting - Ready if MemorySummary.TotalSystemMemoryGiB > 0 OR PCIeDevices.Members non-empty - On failure: wait +60s, retry; on second failure: wait +120s, retry; then warn and proceed - Configurable via LOGPILE_REDFISH_BMC_READY_WAITS (default: 60s,120s) Empty critical collection plan-B retry (EnableEmptyCriticalCollectionRetry): - Hardware inventory collections that returned Members=[] are now re-probed in plan-B - Covers PCIeDevices, NetworkAdapters, Processors, Drives, Storage, EthernetInterfaces - Enabled by default in generic profile (applies to all vendors) Ghost NIC dedup fix (enrichNICsFromNetworkInterfaces): - NetworkInterface entries (e.g. Id=2) that don't match existing NIC slots are now resolved via Links.NetworkAdapter cross-reference to the real Chassis NIC - Prevents duplicate ghost entries (slot=2 "Network Device View") from appearing alongside real NICs (slot="RISER 5 slot 1 (7)") with the same MAC addresses Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
063b08d5fb
commit
125f77ef69
@@ -569,11 +569,12 @@ func (c *RedfishConnector) waitForStablePoweredOnHost(ctx context.Context, clien
|
||||
})
|
||||
}
|
||||
timer := time.NewTimer(stabilizationDelay)
|
||||
defer timer.Stop()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
timer.Stop()
|
||||
return false
|
||||
case <-timer.C:
|
||||
timer.Stop()
|
||||
}
|
||||
}
|
||||
if emit != nil {
|
||||
@@ -583,7 +584,92 @@ func (c *RedfishConnector) waitForStablePoweredOnHost(ctx context.Context, clien
|
||||
Message: "Redfish: повторная проверка PowerState после стабилизации host",
|
||||
})
|
||||
}
|
||||
return c.waitForHostPowerState(ctx, client, req, baseURL, systemPath, true, 5*time.Second)
|
||||
if !c.waitForHostPowerState(ctx, client, req, baseURL, systemPath, true, 5*time.Second) {
|
||||
return false
|
||||
}
|
||||
|
||||
// After the initial stabilization wait, the BMC may still be populating its
|
||||
// hardware inventory (PCIeDevices, memory summary). Poll readiness with
|
||||
// increasing back-off (default: +60s, +120s), then warn and proceed.
|
||||
readinessWaits := redfishBMCReadinessWaits()
|
||||
for attempt, extraWait := range readinessWaits {
|
||||
ready, reason := c.isBMCInventoryReady(ctx, client, req, baseURL, systemPath)
|
||||
if ready {
|
||||
if emit != nil {
|
||||
emit(Progress{
|
||||
Status: "running",
|
||||
Progress: 20,
|
||||
Message: fmt.Sprintf("Redfish: BMC готов (%s)", reason),
|
||||
})
|
||||
}
|
||||
return true
|
||||
}
|
||||
if emit != nil {
|
||||
emit(Progress{
|
||||
Status: "running",
|
||||
Progress: 20,
|
||||
Message: fmt.Sprintf("Redfish: BMC не готов (%s), ожидание %s (попытка %d/%d)", reason, extraWait, attempt+1, len(readinessWaits)),
|
||||
})
|
||||
}
|
||||
timer := time.NewTimer(extraWait)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
timer.Stop()
|
||||
return false
|
||||
case <-timer.C:
|
||||
timer.Stop()
|
||||
}
|
||||
if emit != nil {
|
||||
emit(Progress{
|
||||
Status: "running",
|
||||
Progress: 20,
|
||||
Message: fmt.Sprintf("Redfish: повторная проверка готовности BMC (%d/%d)...", attempt+1, len(readinessWaits)),
|
||||
})
|
||||
}
|
||||
}
|
||||
ready, reason := c.isBMCInventoryReady(ctx, client, req, baseURL, systemPath)
|
||||
if !ready {
|
||||
if emit != nil {
|
||||
emit(Progress{
|
||||
Status: "running",
|
||||
Progress: 20,
|
||||
Message: fmt.Sprintf("Redfish: WARNING — BMC не подтвердил готовность (%s), сбор может быть неполным", reason),
|
||||
})
|
||||
}
|
||||
} else if emit != nil {
|
||||
emit(Progress{
|
||||
Status: "running",
|
||||
Progress: 20,
|
||||
Message: fmt.Sprintf("Redfish: BMC готов (%s)", reason),
|
||||
})
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// isBMCInventoryReady checks whether the BMC has finished populating its
|
||||
// hardware inventory after a power-on. Returns (ready, reason).
|
||||
// It considers the BMC ready if either the system memory summary reports
|
||||
// a non-zero total or the PCIeDevices collection is non-empty.
|
||||
func (c *RedfishConnector) isBMCInventoryReady(ctx context.Context, client *http.Client, req Request, baseURL, systemPath string) (bool, string) {
|
||||
systemDoc, err := c.getJSON(ctx, client, req, baseURL, systemPath)
|
||||
if err != nil {
|
||||
return false, "не удалось прочитать System"
|
||||
}
|
||||
if summary, ok := systemDoc["MemorySummary"].(map[string]interface{}); ok {
|
||||
if asFloat(summary["TotalSystemMemoryGiB"]) > 0 {
|
||||
return true, "MemorySummary заполнен"
|
||||
}
|
||||
}
|
||||
pcieDoc, err := c.getJSON(ctx, client, req, baseURL, joinPath(systemPath, "/PCIeDevices"))
|
||||
if err == nil {
|
||||
if asInt(pcieDoc["Members@odata.count"]) > 0 {
|
||||
return true, "PCIeDevices не пуст"
|
||||
}
|
||||
if members, ok := pcieDoc["Members"].([]interface{}); ok && len(members) > 0 {
|
||||
return true, "PCIeDevices не пуст"
|
||||
}
|
||||
}
|
||||
return false, "MemorySummary=0, PCIeDevices пуст"
|
||||
}
|
||||
|
||||
func (c *RedfishConnector) restoreHostPowerAfterCollection(ctx context.Context, client *http.Client, req Request, baseURL, systemPath string, emit ProgressFn) {
|
||||
@@ -2107,6 +2193,25 @@ func looksLikeRedfishResource(doc map[string]interface{}) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// isHardwareInventoryCollectionPath reports whether the path is a hardware
|
||||
// inventory collection that is expected to have members when the machine is
|
||||
// powered on and the BMC has finished initializing.
|
||||
func isHardwareInventoryCollectionPath(p string) bool {
|
||||
for _, suffix := range []string{
|
||||
"/PCIeDevices",
|
||||
"/NetworkAdapters",
|
||||
"/Processors",
|
||||
"/Drives",
|
||||
"/Storage",
|
||||
"/EthernetInterfaces",
|
||||
} {
|
||||
if strings.HasSuffix(p, suffix) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func shouldSlowProbeCriticalCollection(p string, tuning redfishprofile.AcquisitionTuning) bool {
|
||||
p = normalizeRedfishPath(p)
|
||||
if !tuning.RecoveryPolicy.EnableCriticalSlowProbe {
|
||||
@@ -2427,6 +2532,25 @@ func redfishPowerOnStabilizationDelay() time.Duration {
|
||||
return 60 * time.Second
|
||||
}
|
||||
|
||||
// redfishBMCReadinessWaits returns the extra wait durations used when polling
|
||||
// BMC inventory readiness after power-on. Defaults: [60s, 120s].
|
||||
// Override with LOGPILE_REDFISH_BMC_READY_WAITS (comma-separated durations,
|
||||
// e.g. "60s,120s").
|
||||
func redfishBMCReadinessWaits() []time.Duration {
|
||||
if v := strings.TrimSpace(os.Getenv("LOGPILE_REDFISH_BMC_READY_WAITS")); v != "" {
|
||||
var out []time.Duration
|
||||
for _, part := range strings.Split(v, ",") {
|
||||
if d, err := time.ParseDuration(strings.TrimSpace(part)); err == nil && d >= 0 {
|
||||
out = append(out, d)
|
||||
}
|
||||
}
|
||||
if len(out) > 0 {
|
||||
return out
|
||||
}
|
||||
}
|
||||
return []time.Duration{60 * time.Second, 120 * time.Second}
|
||||
}
|
||||
|
||||
func redfishSnapshotMemoryRequestTimeout() time.Duration {
|
||||
if v := strings.TrimSpace(os.Getenv("LOGPILE_REDFISH_MEMORY_TIMEOUT")); v != "" {
|
||||
if d, err := time.ParseDuration(v); err == nil && d > 0 {
|
||||
@@ -3031,6 +3155,38 @@ func (c *RedfishConnector) recoverCriticalRedfishDocsPlanB(ctx context.Context,
|
||||
addTarget(memberPath)
|
||||
}
|
||||
}
|
||||
|
||||
// Re-probe critical hardware collections that were successfully fetched but
|
||||
// returned no members. This happens when the BMC hasn't finished enumerating
|
||||
// hardware at collection time (e.g. PCIeDevices or NetworkAdapters empty right
|
||||
// after power-on). Only hardware inventory collection suffixes are retried.
|
||||
if tuning.RecoveryPolicy.EnableEmptyCriticalCollectionRetry {
|
||||
for _, p := range criticalPaths {
|
||||
p = normalizeRedfishPath(p)
|
||||
if p == "" {
|
||||
continue
|
||||
}
|
||||
if _, queued := seenTargets[p]; queued {
|
||||
continue
|
||||
}
|
||||
docAny, ok := rawTree[p]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
doc, ok := docAny.(map[string]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if redfishCollectionHasExplicitMembers(doc) {
|
||||
continue
|
||||
}
|
||||
if !isHardwareInventoryCollectionPath(p) {
|
||||
continue
|
||||
}
|
||||
addTarget(p)
|
||||
}
|
||||
}
|
||||
|
||||
if len(targets) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user