collector/redfish: remove pre-snapshot critical duplicate pass
This commit is contained in:
@@ -85,7 +85,6 @@ func (c *RedfishConnector) Collect(ctx context.Context, req Request, emit Progre
|
|||||||
if emit != nil {
|
if emit != nil {
|
||||||
emit(Progress{Status: "running", Progress: 30, Message: "Redfish: чтение структуры Redfish..."})
|
emit(Progress{Status: "running", Progress: 30, Message: "Redfish: чтение структуры Redfish..."})
|
||||||
}
|
}
|
||||||
criticalWarmDocs, criticalWarmErrs := c.collectCriticalRedfishDocsSequential(ctx, criticalClient, req, baseURL, criticalPaths, emit)
|
|
||||||
|
|
||||||
if emit != nil {
|
if emit != nil {
|
||||||
emit(Progress{Status: "running", Progress: 55, Message: "Redfish: подготовка snapshot..."})
|
emit(Progress{Status: "running", Progress: 55, Message: "Redfish: подготовка snapshot..."})
|
||||||
@@ -95,20 +94,7 @@ func (c *RedfishConnector) Collect(ctx context.Context, req Request, emit Progre
|
|||||||
c.debugSnapshotf("snapshot crawl start host=%s port=%d", req.Host, req.Port)
|
c.debugSnapshotf("snapshot crawl start host=%s port=%d", req.Host, req.Port)
|
||||||
rawTree, fetchErrors := c.collectRawRedfishTree(ctx, client, req, baseURL, redfishSnapshotPrioritySeeds(systemPaths, chassisPaths, managerPaths), emit)
|
rawTree, fetchErrors := c.collectRawRedfishTree(ctx, client, req, baseURL, redfishSnapshotPrioritySeeds(systemPaths, chassisPaths, managerPaths), emit)
|
||||||
c.debugSnapshotf("snapshot crawl done docs=%d", len(rawTree))
|
c.debugSnapshotf("snapshot crawl done docs=%d", len(rawTree))
|
||||||
for p, doc := range criticalWarmDocs {
|
|
||||||
if _, ok := rawTree[p]; !ok {
|
|
||||||
rawTree[p] = doc
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fetchErrMap := redfishFetchErrorListToMap(fetchErrors)
|
fetchErrMap := redfishFetchErrorListToMap(fetchErrors)
|
||||||
for p, msg := range criticalWarmErrs {
|
|
||||||
if _, ok := rawTree[p]; ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if _, exists := fetchErrMap[p]; !exists {
|
|
||||||
fetchErrMap[p] = msg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if recoveredN := c.recoverCriticalRedfishDocsPlanB(ctx, criticalClient, req, baseURL, criticalPaths, rawTree, fetchErrMap, emit); recoveredN > 0 {
|
if recoveredN := c.recoverCriticalRedfishDocsPlanB(ctx, criticalClient, req, baseURL, criticalPaths, rawTree, fetchErrMap, emit); recoveredN > 0 {
|
||||||
c.debugSnapshotf("critical plan-b recovered docs=%d", recoveredN)
|
c.debugSnapshotf("critical plan-b recovered docs=%d", recoveredN)
|
||||||
}
|
}
|
||||||
@@ -1332,54 +1318,6 @@ func (c *RedfishConnector) getJSONWithRetry(ctx context.Context, client *http.Cl
|
|||||||
return nil, lastErr
|
return nil, lastErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RedfishConnector) collectCriticalRedfishDocsSequential(ctx context.Context, client *http.Client, req Request, baseURL string, paths []string, emit ProgressFn) (map[string]interface{}, map[string]string) {
|
|
||||||
docs := make(map[string]interface{})
|
|
||||||
errs := make(map[string]string)
|
|
||||||
start := time.Now()
|
|
||||||
total := len(paths)
|
|
||||||
for i, p := range paths {
|
|
||||||
if emit != nil && total > 0 {
|
|
||||||
progress := 30 + int(float64(i)*24.0/float64(total))
|
|
||||||
emit(Progress{
|
|
||||||
Status: "running",
|
|
||||||
Progress: progress,
|
|
||||||
Message: fmt.Sprintf("Redfish critical (%d/%d, ETA≈%s): %s", i+1, total, formatETA(estimateCriticalWarmupETA(start, i, total, client.Timeout)), compactProgressPath(p)),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
doc, err := c.getJSONWithRetry(ctx, client, req, baseURL, p, redfishCriticalRetryAttempts(), redfishCriticalRetryBackoff())
|
|
||||||
if err != nil {
|
|
||||||
errs[p] = err.Error()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
docs[p] = doc
|
|
||||||
// For critical collections, eagerly fetch members sequentially with the same slow policy.
|
|
||||||
if members, ok := c.collectCriticalCollectionMembersSequential(ctx, client, req, baseURL, p, doc); ok {
|
|
||||||
for mp, md := range members {
|
|
||||||
docs[mp] = md
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return docs, errs
|
|
||||||
}
|
|
||||||
|
|
||||||
func estimateCriticalWarmupETA(start time.Time, processed, total int, requestTimeout time.Duration) time.Duration {
|
|
||||||
if total <= 0 || processed >= total {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
remaining := total - processed
|
|
||||||
if processed <= 0 {
|
|
||||||
if requestTimeout <= 0 {
|
|
||||||
requestTimeout = 10 * time.Second
|
|
||||||
}
|
|
||||||
return time.Duration(remaining) * requestTimeout
|
|
||||||
}
|
|
||||||
elapsed := time.Since(start)
|
|
||||||
if elapsed <= 0 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return time.Duration(float64(elapsed) * float64(remaining) / float64(processed))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *RedfishConnector) collectCriticalCollectionMembersSequential(ctx context.Context, client *http.Client, req Request, baseURL, collectionPath string, collectionDoc map[string]interface{}) (map[string]interface{}, bool) {
|
func (c *RedfishConnector) collectCriticalCollectionMembersSequential(ctx context.Context, client *http.Client, req Request, baseURL, collectionPath string, collectionDoc map[string]interface{}) (map[string]interface{}, bool) {
|
||||||
refs, ok := collectionDoc["Members"].([]interface{})
|
refs, ok := collectionDoc["Members"].([]interface{})
|
||||||
if !ok || len(refs) == 0 {
|
if !ok || len(refs) == 0 {
|
||||||
@@ -1415,7 +1353,7 @@ func (c *RedfishConnector) recoverCriticalRedfishDocsPlanB(ctx context.Context,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
errMsg, hasErr := fetchErrs[p]
|
errMsg, hasErr := fetchErrs[p]
|
||||||
if !hasErr || !isRetryableRedfishFetchError(fmt.Errorf("%s", errMsg)) {
|
if hasErr && !isRetryableRedfishFetchError(fmt.Errorf("%s", errMsg)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
targets = append(targets, p)
|
targets = append(targets, p)
|
||||||
|
|||||||
Reference in New Issue
Block a user