ROX-27490: generate partial reports per cluster#15408
Conversation
|
Skipping CI for Draft Pull Request. |
7ecb259 to
3b1318e
Compare
0b7bdbc to
00c6f42
Compare
|
Images are ready for the commit at a743516. To use with deploy scripts, first |
bf9dcf4 to
86c9f07
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #15408 +/- ##
========================================
Coverage 48.75% 48.75%
========================================
Files 2585 2587 +2
Lines 190093 190298 +205
========================================
+ Hits 92671 92771 +100
- Misses 90146 90241 +95
- Partials 7276 7286 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7c413b5 to
aa4e81b
Compare
3b1318e to
438ccf3
Compare
7e35a40 to
0bd6652
Compare
91af2e4 to
9253ce9
Compare
0bd6652 to
3fec723
Compare
vikin91
left a comment
There was a problem hiding this comment.
Posting only partial review - I need to switch to another task, but will continue here later.
central/complianceoperator/v2/report/manager/generator/report_gen_impl.go
Outdated
Show resolved
Hide resolved
central/complianceoperator/v2/report/manager/results/results_aggregator.go
Outdated
Show resolved
Hide resolved
central/complianceoperator/v2/report/manager/results/results_aggregator.go
Outdated
Show resolved
Hide resolved
458c94d to
087d20e
Compare
f2fc1c6 to
c69a973
Compare
a239f56 to
651ff66
Compare
b0bfbd0 to
753eac7
Compare
651ff66 to
7e732ee
Compare
a73e3aa to
714edd8
Compare
vikin91
left a comment
There was a problem hiding this comment.
This PR is huge.. I tried to review without tests in the first pass, but that is a lot.
Posting only partial review so far. Will continue tomorrow.
central/complianceoperator/v2/report/manager/format/formatter.go
Outdated
Show resolved
Hide resolved
central/complianceoperator/v2/report/manager/format/formatter.go
Outdated
Show resolved
Hide resolved
714edd8 to
f3d2c17
Compare
| if clusterData.FailedInfo != nil { | ||
| allScansSet := set.NewStringSet(scans...) | ||
| failedScansSet := set.NewStringSet() | ||
| for _, scan := range clusterData.FailedInfo.Scans { | ||
| failedScansSet.Add(scan.GetScanName()) | ||
| } | ||
| scans = allScansSet.Difference(failedScansSet).AsSlice() |
There was a problem hiding this comment.
Add a test that asserts on the number of scans in this query
There was a problem hiding this comment.
I gave it a try but I'll have to change the test structure to make it work. I'd prefer to do this one in a follow-up.
central/complianceoperator/v2/scans/datastore/datastore_impl_test.go
Outdated
Show resolved
Hide resolved
central/complianceoperator/v2/report/manager/helpers/clusterdata.go
Outdated
Show resolved
Hide resolved
central/complianceoperator/v2/report/manager/helpers/clusterdata.go
Outdated
Show resolved
Hide resolved
central/complianceoperator/v2/report/manager/helpers/clusterdata_test.go
Outdated
Show resolved
Hide resolved
c6d2239 to
2513ff8
Compare
central/complianceoperator/v2/report/manager/results/results_aggregator.go
Outdated
Show resolved
Hide resolved
central/complianceoperator/v2/report/manager/helpers/clusterdata.go
Outdated
Show resolved
Hide resolved
2bd3059 to
a743516
Compare
mtodor
left a comment
There was a problem hiding this comment.
Re-checked all new changes. They look good!
Added a few nitpicks, but I suggest doing them in a follow-up. We should not postpone merging this PR.
| t.Run("failure retrieving snapshot from the store", func(tt *testing.T) { | ||
| snapshotStore.EXPECT(). | ||
| GetLastSnapshotFromScanConfig(gomock.Any(), gomock.Eq(scanConfigID)). | ||
| Times(1).Return(nil, errors.New("some error")) |
There was a problem hiding this comment.
nitpicking: it would be good to test also Return(nil, nil) case.
| return data, nil | ||
| } | ||
|
|
||
| func populateFailedScans(ctx context.Context, failedScanNames []string, snapshotScans []*storage.ComplianceOperatorReportSnapshotV2_Scan, scanStore scanDS.DataStore) ([]*storage.ComplianceOperatorScanV2, error) { |
There was a problem hiding this comment.
nitpick: populateFailedScans name is a bit misleading. We are actually not populating scans here. We are just returning them. Maybe getFailedScans would be a bit more accurate.
For populateScanNames - name stands, because it populates scans in data *report.ClusterData.
| return clusterData, nil | ||
| } | ||
|
|
||
| func populateScanNames(ctx context.Context, data *report.ClusterData, reportData *storage.ComplianceOperatorReportData, clusterID string, scanStore scanDS.DataStore) (*report.ClusterData, error) { |
There was a problem hiding this comment.
nitpick: clusterID is redundant. We could get it from data.ClusterId.
Description
This a follow-up to #15231. Now if a scan fails in a cluster but another one succeeds we do not mark the entire cluster as failed. In those situations we create two reports for that cluster with the following formats:
cluster_<cluster-name>_<ok-profile-1>_<ok-profile_2>_<timestamp>.csvfailed_cluster_<cluster-name>_<nok-profile-3>_<nok-profile_4>_<timestamp>.csvUser-facing documentation
Testing and quality
Automated testing
How I validated my change