Skip to content

CMP-3847: Added TestOperatorResourceLimitsConfigurable tests operator's resource limits and requests can be configured via patching the deployment#1084

Open
taimurhafeez wants to merge 2 commits intoComplianceAsCode:masterfrom
taimurhafeez:CMP-3847
Open

CMP-3847: Added TestOperatorResourceLimitsConfigurable tests operator's resource limits and requests can be configured via patching the deployment#1084
taimurhafeez wants to merge 2 commits intoComplianceAsCode:masterfrom
taimurhafeez:CMP-3847

Conversation

@taimurhafeez
Copy link
Collaborator

@taimurhafeez taimurhafeez commented Feb 11, 2026

TestOperatorResourceLimitsConfigurable verifies that the Compliance Operator's CPU and memory resource limits can be dynamically configured by patching its Deployment object. This ensures that cluster administrators can tune the operator's resource consumption to meet their cluster's needs.

Can be executed:
make e2e-serial E2E_GO_TEST_FLAGS="-v -run TestOperatorResourceLimitsConfigurable"

Expected Output:

=== RUN   TestOperatorResourceLimitsConfigurable
    main_test.go:2185: Verifying default resource limits for compliance-operator
    main_test.go:2215: Patching deployment with new resource limits
2026/02/11 15:44:09 Deployment available (1/1)
    main_test.go:2298: Verifying new resource limits on operator pod
    main_test.go:2335: Successfully verified operator resource limits are configurable
    main_test.go:2248: Restoring original resource limits
2026/02/11 15:44:15 Deployment available (1/1)
--- PASS: TestOperatorResourceLimitsConfigurable (10.75s)
PASS

Used with PR-960.
Assisted by Claude.

…hat Operator's resource limits and requests can be configured via patching the deployment
@openshift-ci
Copy link

openshift-ci bot commented Feb 11, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: taimurhafeez

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

The pull request process is described here

Details 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

@openshift-ci
Copy link

openshift-ci bot commented Feb 11, 2026

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

@taimurhafeez taimurhafeez changed the title First version of TestOperatorResourceLimitsConfigurable that tests that Operator's resource limits and requests can be configured via patching the deployment FCMP-3847: Added TestOperatorResourceLimitsConfigurable tests operator's resource limits and requests can be configured via patching the deployment Feb 11, 2026
@openshift-ci-robot
Copy link
Collaborator

@taimurhafeez: No Jira issue with key FCMP-3847 exists in the tracker at https://issues.redhat.com/.
Once a valid jira issue is referenced in the title of this pull request, request a refresh with /jira refresh.

Details

In response to this:

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 openshift-eng/jira-lifecycle-plugin repository.

@taimurhafeez taimurhafeez changed the title FCMP-3847: Added TestOperatorResourceLimitsConfigurable tests operator's resource limits and requests can be configured via patching the deployment CMP-3847: Added TestOperatorResourceLimitsConfigurable tests operator's resource limits and requests can be configured via patching the deployment Feb 11, 2026
@openshift-ci-robot
Copy link
Collaborator

@taimurhafeez: This pull request references CMP-3847 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

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 openshift-eng/jira-lifecycle-plugin repository.

@github-actions
Copy link

🤖 To deploy this PR, run the following command:

make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1084-2d058b68a1b60439aba6f67d058a512680bafc52

@taimurhafeez taimurhafeez marked this pull request as ready for review February 11, 2026 16:22
@github-actions
Copy link

🤖 To deploy this PR, run the following command:

make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1084-40a43b8d5f74029e9c585955d9b40ccb45d28c53

@openshift-ci
Copy link

openshift-ci bot commented Feb 12, 2026

@taimurhafeez: The following tests 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-rosa 40a43b8 link true /test e2e-rosa
ci/prow/e2e-aws-parallel-arm 40a43b8 link true /test e2e-aws-parallel-arm

Full PR test history. Your PR dashboard.

Details

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.

Copy link
Collaborator

@rhmdnd rhmdnd left a comment

Choose a reason for hiding this comment

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

Couple comments on testing OLM behavior and some recommendations for restoring the defaults.

Thanks for the PR!

"resources": {
"limits": {
"cpu": "200m",
"memory": "500Mi"
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we change these default values in the CSV, the test will revert to a non-default value, right?

We might want to grab the original values and restore those at the end of the test (since these can change).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh - I suppose we're asserting these are the default values above. In that case, the test would already fail.

Maybe we can have the default values as constants?

oldPodUID := podList.Items[0].UID

// Apply the patch
err = f.Client.Patch(context.TODO(), deployment, client.RawPatch(types.StrategicMergePatchType, patchData))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this change persist? Or will OLM revert the operator limits back to what's in the CSV?

https://github.com/ComplianceAsCode/compliance-operator/blob/master/bundle/manifests/compliance-operator.clusterserviceversion.yaml#L1369-L1375

If so, we may need to adjust the test to patch the CSV?

if len(podList.Items) == 0 {
t.Fatal("no compliance-operator pods found before patch")
}
oldPodUID := podList.Items[0].UID
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might break in the off chance the operator is rolling out an update and there is one terminating pod and one running pod. Checking the pod name, it's state, and the list length == 1 might make this more robust.

// NodeSelector: workerNodesLabel,
// ComplianceScanSettings: compv1alpha1.ComplianceScanSettings{
// Debug: true,
// },
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: unrelated whitespace change.

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.

3 participants