Skip to content

NO-JIRA: derive cluster quota from namespace configmaps - #31476

Draft
not-stbenjam wants to merge 1 commit into
openshift:mainfrom
not-stbenjam:agent/clusterquota-observed-configmaps
Draft

NO-JIRA: derive cluster quota from namespace configmaps#31476
not-stbenjam wants to merge 1 commit into
openshift:mainfrom
not-stbenjam:agent/clusterquota-observed-configmaps

Conversation

@not-stbenjam

@not-stbenjam not-stbenjam commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

The ClusterResourceQuota conformance test reserves room for two known namespace ConfigMaps, then has a one-name fallback for istio-ca-root-cert. Recent clusters can have a different third controller-owned ConfigMap in each test namespace; the quota is already full at 6/6, the fallback does not recognize the baseline, and the test fails before exercising its intended quota behavior.

This change creates the two namespaces first, waits for the mandatory CA ConfigMaps, observes the complete ConfigMap baseline in each namespace, and then creates the ClusterResourceQuota with room for exactly the test's two ConfigMaps. The enforcement assertions remain unchanged: one creation in each namespace succeeds and a second creation is forbidden.

Prow evidence:

Corpus impact: 20 exact failed test executions were found across the retained study corpus; 16 already recovered on a twin attempt. The four unrecovered child runs all had independent blocking failures, so the conservative whole-job rescue estimate is 0 even though this removes the flaky assertion and retry pressure.

Validation:

  • GOTOOLCHAIN=auto GOMAXPROCS=2 go test -mod=vendor -vet=off -p=2 -run '^$' ./test/extended/quota
  • git diff --check

No RHCOS or OS-layer evidence was examined.

Summary by CodeRabbit

  • Tests
    • Improved cluster quota test reliability by accounting for pre-existing ConfigMaps.
    • Removed environment-specific assumptions and retry logic.
    • Updated expected quota usage calculations to reflect actual namespace contents.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci-robot

Copy link
Copy Markdown

@not-stbenjam: This pull request explicitly references no jira issue.

Details

In response to this:

The ClusterResourceQuota conformance test reserves room for two known namespace ConfigMaps, then has a one-name fallback for istio-ca-root-cert. Recent clusters can have a different third controller-owned ConfigMap in each test namespace; the quota is already full at 6/6, the fallback does not recognize the baseline, and the test fails before exercising its intended quota behavior.

This change creates the two namespaces first, waits for the mandatory CA ConfigMaps, observes the complete ConfigMap baseline in each namespace, and then creates the ClusterResourceQuota with room for exactly the test's two ConfigMaps. The enforcement assertions remain unchanged: one creation in each namespace succeeds and a second creation is forbidden.

Prow evidence:

Corpus impact: 20 exact failed test executions were found across the retained study corpus; 16 already recovered on a twin attempt. The four unrecovered child runs all had independent blocking failures, so the conservative whole-job rescue estimate is 0 even though this removes the flaky assertion and retry pressure.

Validation:

  • GOTOOLCHAIN=auto GOMAXPROCS=2 go test -mod=vendor -vet=off -p=2 -run '^$' ./test/extended/quota
  • git diff --check

No RHCOS or OS-layer evidence was examined.

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-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 2, 2026
@openshift-ci openshift-ci Bot added ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 2, 2026
@openshift-ci

openshift-ci Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Hi @not-stbenjam. Thanks for your PR.

I'm waiting for a openshift 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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.

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.

@openshift-ci

openshift-ci Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

The full list of commands accepted by this bot can be found 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

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Walkthrough

The cluster quota test now observes existing ConfigMaps in both projects before creating the quota. Usage assertions add newly created ConfigMaps to this observed baseline instead of using fixed counts or Istio-specific recovery logic.

Changes

Cluster quota test

Layer / File(s) Summary
Observe ConfigMap baseline
test/extended/quota/clusterquota.go
The test creates both projects, counts their existing ConfigMaps, and includes the observed count in the ConfigMap quota.
Apply baseline to usage checks
test/extended/quota/clusterquota.go
Expected usage uses the observed baseline plus each newly created ConfigMap. The Istio-specific retry and quota adjustment path is removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning clusterquota.go passes context.Background to WaitForCMState/UntilWithSync and uses many generic "unexpected error" failures, so waits lack deadlines and diagnostics lack operation context. Use context.WithTimeout for ConfigMap waits and add operation- and namespace-specific messages to each failure assertion.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: deriving cluster quota from existing namespace ConfigMaps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The commit changes only quota setup logic; its Ginkgo titles are static literals and contain no generated names, timestamps, namespaces, IPs, or other run-dependent values.
Microshift Test Compatibility ✅ Passed The modified Ginkgo test uses unavailable OpenShift APIs but its name includes [apigroup:quota.openshift.io], [apigroup:image.openshift.io], [apigroup:monitoring.coreos.com], and [apigroup:template...
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR modifies an existing ClusterResourceQuota test and adds no new Ginkgo test; it uses namespace-scoped APIs and makes no multi-node or HA assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed The patch changes only test/extended/quota/clusterquota.go and adds no deployment, operator, controller, replica, affinity, topology, toleration, node selector, or PDB scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The change adds no direct stdout or klog writes; its new framework.Logf call is inside g.It, and framework.Logf writes to GinkgoWriter.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The change only lists in-cluster ConfigMaps and adjusts quota accounting; it adds no IPv4 literals, IP parsing, URLs, public hosts, downloads, or external connectivity.
No-Weak-Crypto ✅ Passed The PR changes only clusterquota.go. Added code uses Kubernetes quota/configmap APIs and contains no MD5, SHA1, DES, RC4, Blowfish, ECB, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed The PR changes only test/extended/quota/clusterquota.go; its added lines contain no container or Kubernetes privilege settings.
No-Sensitive-Data-In-Logs ✅ Passed The change logs only fixed ConfigMap names, generated test namespace names, and counts. It adds no logging of passwords, tokens, API keys, PII, hostnames, or customer data.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/extended/quota/clusterquota.go (1)

79-106: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Read the active quota used count before adding headroom.

The ConfigMap baseline is taken by ConfigMaps(ns).List() before cq is created and before the namespaces are labeled into the selector. If a cluster controller creates a ConfigMap after that list but before the quota controller syncs, quota.Status.Total.Used[corev1.ResourceConfigMaps] will include it while cq.Spec.Quota.Hard still equals initialConfigMapCount + 2. That can make the legitimate creates at the expected counts fail with Forbidden and fail the e2e immediately.

Use the quota-controller-observed baseline (for example, Status.Total.Used[corev1.ResourceConfigMaps] after waitForQuotaStatus confirms the quota is active) before adding the test’s two planned ConfigMap creations.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/extended/quota/clusterquota.go` around lines 79 - 106, Use the
quota-controller-observed ConfigMap usage as the baseline instead of the
pre-creation namespace list. After waitForQuotaStatus confirms the cluster quota
is active, read cq.Status.Total.Used[corev1.ResourceConfigMaps], then add
headroom for the two planned creations when setting cq.Spec.Quota.Hard; retain
the existing initial list only if needed for logging or setup.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@test/extended/quota/clusterquota.go`:
- Around line 79-106: Use the quota-controller-observed ConfigMap usage as the
baseline instead of the pre-creation namespace list. After waitForQuotaStatus
confirms the cluster quota is active, read
cq.Status.Total.Used[corev1.ResourceConfigMaps], then add headroom for the two
planned creations when setting cq.Spec.Quota.Hard; retain the existing initial
list only if needed for logging or setup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: d99302b9-c78a-4abd-b678-f400df4cc200

📥 Commits

Reviewing files that changed from the base of the PR and between e3c4a6b and 98a3c88.

📒 Files selected for processing (1)
  • test/extended/quota/clusterquota.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants