Skip to content

fix: surface namespace cache errors and avoid redundant VAP status updates (CP #4656, CP #4703) - #4795

Merged
JaydipGabani merged 2 commits into
open-policy-agent:release-3.23from
abhisheksheth28:cherry-pick-4656-4703
Aug 27, 2026
Merged

fix: surface namespace cache errors and avoid redundant VAP status updates (CP #4656, CP #4703)#4795
JaydipGabani merged 2 commits into
open-policy-agent:release-3.23from
abhisheksheth28:cherry-pick-4656-4703

Conversation

@abhisheksheth28

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
(cherry picked from commit 68079d0)
(cherry picked from commit 6f898fe)

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Fixes #

Special notes for your reviewer:

ogulcanaydogan and others added 2 commits August 27, 2026 00:50
…-agent#4656)

Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@gmail.com>
Co-authored-by: Jaydip Gabani <gabanijaydip@gmail.com>
(cherry picked from commit 68079d0)
Signed-off-by: Jaydip Gabani <gabanijaydip@gmail.com>
(cherry picked from commit 6f898fe)
Copilot AI balanced review requested due to automatic review settings August 27, 2026 07:59
@abhisheksheth28
abhisheksheth28 requested a review from a team as a code owner August 27, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Backports fixes for namespace cache diagnostics and redundant VAP/VAPB status writes.

Changes:

  • Wraps underlying namespace conversion errors.
  • Persists controller status only when semantically changed.
  • Improves VAP eligibility handling and related tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/target/ns_cache.go Surfaces namespace conversion errors.
pkg/controller/constrainttemplate/constrainttemplate_controller.go Deduplicates template status writes.
pkg/controller/constrainttemplate/constrainttemplate_controller_test.go Tests template status persistence.
pkg/controller/constraint/constraint_controller.go Deduplicates constraint status writes and refines VAPB handling.
pkg/controller/constraint/constraint_controller_test.go Adds VAPB status regression coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +670 to +679
case err != nil:
log.Error(err, "could not determine if ConstraintTemplate is configured to generate ValidatingAdmissionPolicy", "constraint", instance.GetName(), "constraint_template", unversionedCT.GetName())
r.reporter.ReportVAPBStatus(vapBindingKey, metrics.VAPStatusError)
status.Status.Errors = append(status.Status.Errors, constraintstatusv1beta1.Error{Message: fmt.Sprintf("could not determine if ConstraintTemplate is configured to generate ValidatingAdmissionPolicy: %s", err)})
shouldGenerateVAPB = false
case !hasVAP:
log.Error(ErrVAPConditionsNotSatisfied, "Cannot generate ValidatingAdmissionPolicyBinding", "constraint", instance.GetName(), "constraint_template", unversionedCT.GetName())
r.reporter.ReportVAPBStatus(vapBindingKey, metrics.VAPStatusError)
status.Status.Errors = append(status.Status.Errors, constraintstatusv1beta1.Error{Message: fmt.Sprintf("cannot generate ValidatingAdmissionPolicyBinding: %s", ErrVAPConditionsNotSatisfied)})
shouldGenerateVAPB = false
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.83333% with 29 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-3.23@c19d983). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pkg/controller/constraint/constraint_controller.go 64.63% 23 Missing and 6 partials ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##             release-3.23    #4795   +/-   ##
===============================================
  Coverage                ?   45.47%           
===============================================
  Files                   ?      284           
  Lines                   ?    21104           
  Branches                ?        0           
===============================================
  Hits                    ?     9596           
  Misses                  ?    10695           
  Partials                ?      813           
Flag Coverage Δ
unittests 45.47% <75.83%> (?)

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JaydipGabani
JaydipGabani merged commit 00eab8b into open-policy-agent:release-3.23 Aug 27, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants