Skip to content

ROX-27490: generate partial reports per cluster#15408

Merged
lvalerom merged 7 commits intomasterfrom
lvm/rox-27490-generate-partial-reports-per-cluster
Jun 4, 2025
Merged

ROX-27490: generate partial reports per cluster#15408
lvalerom merged 7 commits intomasterfrom
lvm/rox-27490-generate-partial-reports-per-cluster

Conversation

@lvalerom
Copy link
Contributor

@lvalerom lvalerom commented May 22, 2025

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:

  • File with the results of the successful scans cluster_<cluster-name>_<ok-profile-1>_<ok-profile_2>_<timestamp>.csv
  • File with the failure reasons of the failed scans failed_cluster_<cluster-name>_<nok-profile-3>_<nok-profile_4>_<timestamp>.csv

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  • Unit tests added
  • Manual testing:
    • Deploy in two clusters with Compliance Operator
    • Create a Scan Schedule with both cluster
    • Make one of the scans fail mid scan (e.g. disconnect sensor from central) after other scans are reported as successful
    • Observe the report has two files for the partially failed cluster and the content of the files is correct.

@openshift-ci
Copy link

openshift-ci bot commented May 22, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@lvalerom lvalerom force-pushed the lvm/rox-27490-handle-failed-clusters branch from 7ecb259 to 3b1318e Compare May 22, 2025 13:42
@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch from 0b7bdbc to 00c6f42 Compare May 22, 2025 13:49
@rhacs-bot
Copy link
Contributor

rhacs-bot commented May 22, 2025

Images are ready for the commit at a743516.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.8.x-930-ga743516256.

@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch 4 times, most recently from bf9dcf4 to 86c9f07 Compare May 22, 2025 17:32
@codecov
Copy link

codecov bot commented May 22, 2025

Codecov Report

Attention: Patch coverage is 80.10471% with 38 lines in your changes missing coverage. Please review.

Project coverage is 48.75%. Comparing base (9111ac8) to head (a743516).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...mplianceoperator/v2/report/manager/manager_impl.go 50.00% 19 Missing and 7 partials ⚠️
...anceoperator/v2/report/datastore/datastore_impl.go 76.92% 2 Missing and 1 partial ⚠️
...anceoperator/v2/report/manager/format/formatter.go 86.36% 2 Missing and 1 partial ⚠️
...eoperator/v2/report/manager/helpers/clusterdata.go 95.52% 2 Missing and 1 partial ⚠️
...or/v2/report/manager/results/results_aggregator.go 84.21% 2 Missing and 1 partial ⚠️
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     
Flag Coverage Δ
go-unit-tests 48.75% <80.10%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch 4 times, most recently from 7c413b5 to aa4e81b Compare May 23, 2025 16:48
@lvalerom lvalerom mentioned this pull request May 26, 2025
11 tasks
@lvalerom lvalerom force-pushed the lvm/rox-27490-handle-failed-clusters branch from 3b1318e to 438ccf3 Compare May 26, 2025 16:42
@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch from 7e35a40 to 0bd6652 Compare May 27, 2025 13:22
@lvalerom lvalerom force-pushed the lvm/rox-27490-handle-failed-clusters branch from 91af2e4 to 9253ce9 Compare May 27, 2025 16:07
@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch from 0bd6652 to 3fec723 Compare May 28, 2025 11:04
@lvalerom lvalerom marked this pull request as ready for review May 28, 2025 11:13
@lvalerom lvalerom requested review from mtodor and vikin91 May 28, 2025 11:13
Copy link
Contributor

@vikin91 vikin91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posting only partial review - I need to switch to another task, but will continue here later.

Base automatically changed from lvm/rox-27490-handle-failed-clusters to master May 28, 2025 13:59
@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch 2 times, most recently from 458c94d to 087d20e Compare May 30, 2025 05:34
@lvalerom lvalerom requested a review from a team as a code owner May 30, 2025 05:34
@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch 5 times, most recently from f2fc1c6 to c69a973 Compare May 30, 2025 09:41
@lvalerom lvalerom force-pushed the lvm/rox-29251-add-last-started-field-to-check-results-proto branch from a239f56 to 651ff66 Compare May 30, 2025 16:02
@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch 2 times, most recently from b0bfbd0 to 753eac7 Compare May 30, 2025 17:01
@lvalerom lvalerom force-pushed the lvm/rox-29251-add-last-started-field-to-check-results-proto branch from 651ff66 to 7e732ee Compare June 2, 2025 08:43
@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch 2 times, most recently from a73e3aa to 714edd8 Compare June 2, 2025 13:13
Copy link
Contributor

@vikin91 vikin91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Base automatically changed from lvm/rox-29251-add-last-started-field-to-check-results-proto to master June 3, 2025 05:50
@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch from 714edd8 to f3d2c17 Compare June 3, 2025 06:01
Comment on lines +102 to +108
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()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test that asserts on the number of scans in this query

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch 2 times, most recently from c6d2239 to 2513ff8 Compare June 3, 2025 15:33
@lvalerom lvalerom force-pushed the lvm/rox-27490-generate-partial-reports-per-cluster branch from 2bd3059 to a743516 Compare June 4, 2025 06:43
Copy link
Contributor

@mtodor mtodor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: clusterID is redundant. We could get it from data.ClusterId.

@lvalerom
Copy link
Contributor Author

lvalerom commented Jun 4, 2025

@mtodor @vikin91 I've resolved all the comments to be able to merge but I'll follow up on them.

@lvalerom lvalerom merged commit 218830d into master Jun 4, 2025
102 checks passed
@lvalerom lvalerom deleted the lvm/rox-27490-generate-partial-reports-per-cluster branch June 4, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants