collector/redfish: fix server model fallback and GPU/NVMe regressions
This commit is contained in:
@@ -460,7 +460,7 @@ func (c *RedfishConnector) collectGPUs(ctx context.Context, client *http.Client,
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
return dropModelOnlyGPUPlaceholders(out)
|
||||
}
|
||||
|
||||
func (c *RedfishConnector) collectPCIeDevices(ctx context.Context, client *http.Client, req Request, baseURL string, systemPaths, chassisPaths []string) []models.PCIeDevice {
|
||||
@@ -2070,7 +2070,9 @@ func shouldSkipGenericGPUDuplicate(existing []models.GPU, candidate models.GPU)
|
||||
if !strings.EqualFold(strings.TrimSpace(gpu.Model), model) {
|
||||
continue
|
||||
}
|
||||
if !strings.EqualFold(strings.TrimSpace(gpu.Manufacturer), strings.TrimSpace(candidate.Manufacturer)) {
|
||||
existingMfr := strings.TrimSpace(gpu.Manufacturer)
|
||||
candidateMfr := strings.TrimSpace(candidate.Manufacturer)
|
||||
if existingMfr != "" && candidateMfr != "" && !strings.EqualFold(existingMfr, candidateMfr) {
|
||||
continue
|
||||
}
|
||||
if normalizeRedfishIdentityField(gpu.SerialNumber) != "" || strings.TrimSpace(gpu.BDF) != "" {
|
||||
@@ -2080,6 +2082,41 @@ func shouldSkipGenericGPUDuplicate(existing []models.GPU, candidate models.GPU)
|
||||
return false
|
||||
}
|
||||
|
||||
func dropModelOnlyGPUPlaceholders(items []models.GPU) []models.GPU {
|
||||
if len(items) < 2 {
|
||||
return items
|
||||
}
|
||||
|
||||
concreteByModel := make(map[string]struct{}, len(items))
|
||||
for _, gpu := range items {
|
||||
modelKey := strings.ToLower(strings.TrimSpace(gpu.Model))
|
||||
if modelKey == "" {
|
||||
continue
|
||||
}
|
||||
if normalizeRedfishIdentityField(gpu.SerialNumber) != "" || strings.TrimSpace(gpu.BDF) != "" {
|
||||
concreteByModel[modelKey] = struct{}{}
|
||||
}
|
||||
}
|
||||
if len(concreteByModel) == 0 {
|
||||
return items
|
||||
}
|
||||
|
||||
out := make([]models.GPU, 0, len(items))
|
||||
for _, gpu := range items {
|
||||
modelKey := strings.ToLower(strings.TrimSpace(gpu.Model))
|
||||
slot := strings.TrimSpace(gpu.Slot)
|
||||
if _, hasConcrete := concreteByModel[modelKey]; hasConcrete &&
|
||||
normalizeRedfishIdentityField(gpu.SerialNumber) == "" &&
|
||||
strings.TrimSpace(gpu.BDF) == "" &&
|
||||
(strings.EqualFold(slot, strings.TrimSpace(gpu.Model)) ||
|
||||
strings.HasPrefix(strings.ToUpper(slot), "GPU")) {
|
||||
continue
|
||||
}
|
||||
out = append(out, gpu)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func looksLikeGPU(doc map[string]interface{}, functionDocs []map[string]interface{}) bool {
|
||||
deviceType := strings.ToLower(asString(doc["DeviceType"]))
|
||||
if strings.Contains(deviceType, "gpu") || strings.Contains(deviceType, "graphics") || strings.Contains(deviceType, "accelerator") {
|
||||
@@ -2183,7 +2220,10 @@ func dedupeStorage(items []models.Storage) []models.Storage {
|
||||
out := make([]models.Storage, 0, len(items))
|
||||
seen := make(map[string]struct{}, len(items))
|
||||
for _, item := range items {
|
||||
key := firstNonEmpty(item.SerialNumber, item.Slot+"|"+item.Model)
|
||||
key := firstNonEmpty(
|
||||
normalizeRedfishIdentityField(item.SerialNumber),
|
||||
strings.TrimSpace(item.Slot)+"|"+strings.TrimSpace(item.Model),
|
||||
)
|
||||
if key == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user