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 enhancement last-scanned-timestamps #501

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SimonBaeumer
Copy link

@SimonBaeumer SimonBaeumer commented Apr 10, 2024

This PR adds an enhancement to add a field LastScannedTimestamp to the CheckResult CR.

This enhancement is planned to be implemented by myself. This first iteration is to get consensus on the feature request and discuss possible implementations if necessary.

Copy link

openshift-ci bot commented Apr 10, 2024

Hi @SimonBaeumer. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

openshift-ci bot commented Apr 10, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: SimonBaeumer
Once this PR has been reviewed and has the lgtm label, please assign mrogers950 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhmdnd rhmdnd requested review from yuumasato, mkumku, sheriff-rh and Vincent056 and removed request for jhrozek April 12, 2024 19:59
@rhmdnd
Copy link

rhmdnd commented Apr 12, 2024

/ok-to-test


## Proposal

Add a `LastTimeStamp` field to the `ComplianceCheckResult` which is updated after every scan.
Copy link

Choose a reason for hiding this comment

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

I just realized we have a similar field already on the ComplianceSuite and ComplianceScan objects:

╭─lbragstad@p1 ~
╰─➤  $ oc get scans -o json ocp4-cis | jq .status.conditions
[
  {
    "lastTransitionTime": "2024-04-12T20:21:52Z",
    "message": "Compliance scan run is done running the scans",
    "reason": "NotRunning",
    "status": "False",
    "type": "Processing"
  },
  {
    "lastTransitionTime": "2024-04-12T20:21:52Z",
    "message": "Compliance scan run is done and has results",
    "reason": "Done",
    "status": "True",
    "type": "Ready"
  }
]
╭─lbragstad@p1 ~
╰─➤  $ oc get suites -o json cis | jq .status.conditions
[
  {
    "lastTransitionTime": "2024-04-12T20:21:52Z",
    "message": "Compliance suite run is done running the scans",
    "reason": "NotRunning",
    "status": "False",
    "type": "Processing"
  },
  {
    "lastTransitionTime": "2024-04-12T20:21:52Z",
    "message": "Compliance suite run is done and has results",
    "reason": "Done",
    "status": "True",
    "type": "Ready"
  }
]

To keep things consistent, I wonder if we can just implement status conditions on ComplianceCheckResults.


## Summary

ACS implements an integration with Compliance Operator. For this, ACS reports when a scan was completed. Currently
Copy link

Choose a reason for hiding this comment

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

I think the part that makes this tricky is that the data is only flowing one way (from sensor to central). Without a definitive signal that tells central "yep, you have everything" it's required to make an assumption (e.g., I've waited 5 minutes without anything new coming in from this particular suite, which is marked as DONE, I should be safe to build a report?).

Copy link
Author

Choose a reason for hiding this comment

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

We could also implement like this:
After a scan report is triggered, wait until ComplianceSuite is in state DONE, than read all results and check that the lastScannedTimestamp is after the last triggered scan time.
If not, retry 10 minutes later.
Would require a small go routine background job though to manage this.

@rhmdnd How likely do you even think it is that a result is send after the suite reports DONE?
Imho we could also implement a small buffer of some minutes after which the the report is sent.

Choose a reason for hiding this comment

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

Not just a report problem. ACS simply has no way to know if the results match an iteration of a scan.

Copy link
Author

Choose a reason for hiding this comment

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

Not just a report problem. ACS simply has no way to know if the results match an iteration of a scan.

Is a guarantee necessary or the current implementation "good enough"?

If a guarantee is necessary we would need some kind of a UUID per CO scan.

Copy link

Choose a reason for hiding this comment

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

What if the ComplianceScan object contained a counter with the number of ComplianceCheckResults it generated the most recent run? Then consumers would have a known quantity to check for.

Copy link
Author

Choose a reason for hiding this comment

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

@rhmdnd Is the ComplianceScan object aware of the total check results it creates?

Copy link

Choose a reason for hiding this comment

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

As an integer, it isn't. We could implement that though in the Reconcile loop of the ComplianceScan and tack that number onto the scan.

@xiaojiey
Copy link
Collaborator

/hold for test

@SimonBaeumer
Copy link
Author

See #512

Copy link

openshift-ci bot commented Jul 19, 2024

@SimonBaeumer: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-serial fec136e link true /test e2e-aws-serial

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@rhmdnd rhmdnd added this to the 1.6.0 milestone Aug 9, 2024
@Vincent056
Copy link

we have implmentation in #591

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.

None yet

5 participants