Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an "all results" query to scanner/fixer workflows #5470

Merged
merged 6 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions service/worker/scanner/shardscanner/aggregators.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ func (a *ShardFixResultAggregator) GetReport(shardID int) (*FixReport, error) {
return nil, fmt.Errorf("shard %v has not finished yet, check back later for report", shardID)
}

func (a *ShardFixResultAggregator) GetAllFixResults() (map[int]FixResult, error) {
result := make(map[int]FixResult, len(a.reports))
for k, v := range a.reports {
result[k] = v.Result
}
return result, nil
}

func (a *ShardFixResultAggregator) adjustAggregation(stats FixStats, fn func(a, b int64) int64) {
a.aggregation.EntitiesCount = fn(a.aggregation.EntitiesCount, stats.EntitiesCount)
a.aggregation.SkippedCount = fn(a.aggregation.SkippedCount, stats.SkippedCount)
Expand Down Expand Up @@ -557,6 +565,14 @@ func (a *ShardScanResultAggregator) adjustAggregation(stats ScanStats, fn func(a
}
}

func (a *ShardScanResultAggregator) GetAllScanResults() (map[int]ScanResult, error) {
result := make(map[int]ScanResult, len(a.reports))
for k, v := range a.reports {
result[k] = v.Result
}
return result, nil
}

func getStatusResult(
minShardID int,
maxShardID int,
Expand Down
6 changes: 6 additions & 0 deletions service/worker/scanner/shardscanner/fixer_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ func setHandlers(aggregator *ShardFixResultAggregator) map[string]interface{} {
}
return aggregator.GetDomainStatus(req)
},
AllResultsQuery: func() (map[int]FixResult, error) {
if aggregator == nil {
return nil, errQueryNotReady
}
return aggregator.GetAllFixResults()
},
}
}

Expand Down
11 changes: 11 additions & 0 deletions service/worker/scanner/shardscanner/scanner_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ const (
ShardSizeQuery = "shard_size"
// DomainReportQuery is the query name for the query used to get the reports per domains for all finished shards
DomainReportQuery = "domain_report"
// AllResultsQuery returns filenames / paginating data for corruptions and failures in this workflow,
// for shards which have finished processing. This works for both scanner and fixer, and the return structures
// are very similar.
//
// This data is also available for a single shard under ShardReportQuery, but using that requires
// re-querying repeatedly if more than that single shard's data is desired, e.g. for manual
// troubleshooting purposes.
AllResultsQuery = "all_results"

scanShardReportChan = "scanShardReportChan"
)
Expand Down Expand Up @@ -206,6 +214,9 @@ func getScanHandlers(aggregator *ShardScanResultAggregator) map[string]interface
DomainReportQuery: func(req DomainReportQueryRequest) (*DomainScanReportQueryResult, error) {
return aggregator.GetDomainStatus(req)
},
AllResultsQuery: func() (map[int]ScanResult, error) {
return aggregator.GetAllScanResults()
},
}
}

Expand Down