Skip to content

CMP-3857: Add e2e test for api-resource-collector memory under load - #1181

Open
taimurhafeez wants to merge 1 commit into
ComplianceAsCode:masterfrom
taimurhafeez:CMP-3857-fix-oom-test
Open

taimurhafeez wants to merge 1 commit into
ComplianceAsCode:masterfrom
taimurhafeez:CMP-3857-fix-oom-test

Conversation

@taimurhafeez

@taimurhafeez taimurhafeez commented Apr 20, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #1126.

The api-resource-collector reads every API path the content asks for
into memory and runs under a 202Mi limit, which makes it the component
that runs out of memory first in a large environment. It has been
OOMKilled before, fetching the MachineConfigs the PCI-DSS profile
examines, which is why mcStreamer pages through the MachineConfig list
and drops each object's Ignition file contents before collecting it.
Nothing covered that.

Add TestAPIResourceCollectorHandlesLargeMachineConfigs to the prerelease
suite. It creates 60 MachineConfigs carrying ~900KiB of Ignition file
content each, runs a platform scan, and fails if the collector is
OOMKilled. Correct code holds one page, five objects, at a time; without
the paging or the stripping all ~53MiB materialize at once and the
collector is killed. The MachineConfigs carry a role no
MachineConfigPool selects, so the MachineConfigOperator renders nothing
from them and no node reboots, and the test removes them afterwards.

Scan pods restart on failure, so an OOMKilled collector would otherwise
surface only as the scan never reaching DONE, long after the fact.
WaitForAPIResourceCollector watches the init container's status and
reports the kill as soon as the kubelet records it, in
LastTerminationState once the container is restarting, and including
when the runtime reports only SIGKILL rather than OOMKilled.

The paths the collector fetches come from the content, not from the
operator, so the test also checks the collector's log for the whole
MachineConfig list path. If a future datastream stops asking for the
list, the load never reaches the collector, and this fails saying so
instead of passing without exercising anything.

This replaces the operator-pod memory test the change started out as.
The operator's manager cache is scoped to WATCH_NAMESPACE, so the
namespace count does not grow it, and measuring the operator pod could
not have caught a collector OOM.

Co-Authored-By: Claude Opus 5 noreply@anthropic.com

@openshift-ci-robot

Copy link
Copy Markdown
Collaborator

@taimurhafeez: This pull request references CMP-3857 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 "5.0.0" version, but no target version was set.

Details

In response to this:

Supersedes #1126.

This test verifies that the compliance operator does not experience excessive memory growth when there are many namespaces in the cluster.

The test creates 600 namespaces with network policies, runs a compliance scan, and measures memory usage before and after. It ensures that memory increase stays under 60Mi threshold to prevent OOM issues.

Test coverage:

  • Operator memory stability with 600+ namespaces
  • Proper handling of namespace scaling
  • Prevention of OOMKilled status under stress

Run on OCP 4.22:
make e2e-prerelease E2E_GO_TEST_FLAGS="-v -run TestOperatorMemoryWithManyNamespaces"
--- PASS: TestOperatorMemoryWithManyNamespaces (296.15s)

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.

@openshift-ci
openshift-ci Bot requested a review from xiaojiey April 20, 2026 11:52
@openshift-ci

openshift-ci Bot commented Apr 20, 2026

Copy link
Copy Markdown

[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
openshift-ci Bot requested a review from yuumasato April 20, 2026 11:52
@github-actions

Copy link
Copy Markdown

🤖 To deploy this PR, run the following command:

make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1181-84fc6c9981de926befb03be1997be6c9725017bc

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown

Stale PRs are closed after 21d of inactivity.

If this PR is still relevant, comment to refresh it or remove the stale label.
Mark the PR as fresh by commenting /remove-lifecycle stale.

If this PR is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci

openshift-ci Bot commented Aug 12, 2026

Copy link
Copy Markdown

Stale PRs rot after 14d of inactivity.

Mark the PR as fresh by commenting /remove-lifecycle rotten.
Rotten PRs close after an additional 7d of inactivity.

If this PR is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@taimurhafeez

Copy link
Copy Markdown
Collaborator Author

/remove-lifecycle rotten

@github-actions

Copy link
Copy Markdown

🤖 To deploy this PR, run the following command:

make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1181-fed823068c4590f267bd4203b88d1d7366ffe864

@openshift-ci

openshift-ci Bot commented Sep 13, 2026

Copy link
Copy Markdown

Stale PRs are closed after 21d of inactivity.

If this PR is still relevant, comment to refresh it or remove the stale label.
Mark the PR as fresh by commenting /remove-lifecycle stale.

If this PR is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci

openshift-ci Bot commented Sep 27, 2026

Copy link
Copy Markdown

Stale PRs rot after 14d of inactivity.

Mark the PR as fresh by commenting /remove-lifecycle rotten.
Rotten PRs close after an additional 7d of inactivity.

If this PR is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci

openshift-ci Bot commented Oct 4, 2026

Copy link
Copy Markdown

Rotten PRs close after 7d of inactivity.

Reopen the PR by commenting /reopen.
Mark the PR as fresh by commenting /remove-lifecycle rotten.

/close

@openshift-ci openshift-ci Bot closed this Oct 4, 2026
@openshift-ci

openshift-ci Bot commented Oct 4, 2026

Copy link
Copy Markdown

@openshift-ci[bot]: Closed this PR.

Details

In response to this:

Rotten PRs close after 7d of inactivity.

Reopen the PR by commenting /reopen.
Mark the PR as fresh by commenting /remove-lifecycle rotten.

/close

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.

@rhmdnd rhmdnd reopened this Oct 26, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Collaborator

@taimurhafeez: This pull request references CMP-3857 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 "5.1.0" version, but no target version was set.

Details

In response to this:

Supersedes #1126.

This test verifies that the compliance operator does not experience excessive memory growth when there are many namespaces in the cluster.

The test creates 600 namespaces with network policies, runs a compliance scan, and measures memory usage before and after. It ensures that memory increase stays under 60Mi threshold to prevent OOM issues.

Test coverage:

  • Operator memory stability with 600+ namespaces
  • Proper handling of namespace scaling
  • Prevention of OOMKilled status under stress

Run on OCP 4.22:
make e2e-prerelease E2E_GO_TEST_FLAGS="-v -run TestOperatorMemoryWithManyNamespaces"
--- PASS: TestOperatorMemoryWithManyNamespaces (296.15s)

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.

The api-resource-collector reads every API path the content asks for
into memory and runs under a 202Mi limit, which makes it the component
that runs out of memory first in a large environment. It has been
OOMKilled before, fetching the MachineConfigs the PCI-DSS profile
examines, which is why mcStreamer pages through the MachineConfig list
and drops each object's Ignition file contents before collecting it.
Nothing covered that.

Add TestAPIResourceCollectorHandlesLargeMachineConfigs to the prerelease
suite. It creates 60 MachineConfigs carrying ~900KiB of Ignition file
content each, runs a platform scan, and fails if the collector is
OOMKilled. Correct code holds one page, five objects, at a time; without
the paging or the stripping all ~53MiB materialize at once and the
collector is killed. The MachineConfigs carry a role no
MachineConfigPool selects, so the MachineConfigOperator renders nothing
from them and no node reboots, and the test removes them afterwards.

Scan pods restart on failure, so an OOMKilled collector would otherwise
surface only as the scan never reaching DONE, long after the fact.
WaitForAPIResourceCollector watches the init container's status and
reports the kill as soon as the kubelet records it, in
LastTerminationState once the container is restarting, and including
when the runtime reports only SIGKILL rather than OOMKilled.

The paths the collector fetches come from the content, not from the
operator, so the test also checks the collector's log for the whole
MachineConfig list path. If a future datastream stops asking for the
list, the load never reaches the collector, and this fails saying so
instead of passing without exercising anything.

This replaces the operator-pod memory test the change started out as.
The operator's manager cache is scoped to WATCH_NAMESPACE, so the
namespace count does not grow it, and measuring the operator pod could
not have caught a collector OOM.

Co-authored-by: Taimur Hafeez <taimurhafeez93@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rhmdnd
rhmdnd force-pushed the CMP-3857-fix-oom-test branch from fed8230 to 71f3295 Compare October 26, 2026 22:12
@rhmdnd rhmdnd changed the title CMP-3857: Add prerelease e2e test for operator memory with many namespaces. CMP-3857: Add e2e test for api-resource-collector memory under load Oct 26, 2026
@rhmdnd
rhmdnd requested review from Vincent056 and removed request for xiaojiey October 26, 2026 22:14
@github-actions

Copy link
Copy Markdown

🤖 To deploy this PR, run the following command:

make catalog-deploy CATALOG_IMG=ghcr.io/complianceascode/compliance-operator-catalog:1181-71f3295081e21e0f7d36ac1aeb3594a93da044fd

@openshift-ci

openshift-ci Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

@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-aws-config 84fc6c9 link true /test e2e-aws-config
ci/prow/e2e-rosa 84fc6c9 link true /test e2e-rosa
ci/prow/e2e-aws-serial-arm 84fc6c9 link true /test e2e-aws-serial-arm
ci/prow/e2e-aws-tls-scanner fed8230 link false /test e2e-aws-tls-scanner
ci/prow/e2e-aws-tls-scanner-5-0 fed8230 link false /test e2e-aws-tls-scanner-5-0
ci/prow/e2e-aws-prerelease 71f3295 link true /test e2e-aws-prerelease

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.

// Match the whole logged URI. The list path is a prefix of the paths that
// name a single MachineConfig, and those are fetched whole by uriStreamer,
// which is not what this test is about.
if !strings.Contains(logs, fmt.Sprintf("Fetching URI: '%s'", mcListPath)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems brittle... if we change the logging output, we could introduce a regression.

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