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

fix: fixing error reporting for templates without CEL #3493

Merged
merged 2 commits into from
Aug 14, 2024

Conversation

JaydipGabani
Copy link
Contributor

@JaydipGabani JaydipGabani commented Aug 13, 2024

What this PR does / why we need it:
This PR makes sure that VAPBinding generation error are reported only on constraint that belong to CT where Code[_].engine == K8sNativeValidation

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 #3492

Special notes for your reviewer:

…gent#3492

Signed-off-by: Jaydip Gabani <gabanijaydip@gmail.com>
@JaydipGabani JaydipGabani requested a review from a team as a code owner August 13, 2024 02:17
if err != nil {
switch {
case errors.Is(err, celSchema.ErrCodeNotDefined):
generateVAPB = false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we want to log warning here?

log.V(1).Info("Warning: Template is not configured to create ValidatingAadmissionPolicy, cannot create ValidatingAdmissionPolicyBinding")

would this be leaking information intended for template to constraints?

Copy link
Member

Choose a reason for hiding this comment

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

IMO we should log and update status ONLY if code.engine is K8sNativeValidation. Otherwise this error will appear for all older rego CTs as code.source was introduced recently.

e.g. of older regos CTs:

targets:
    - target: admission.k8s.gatekeeper.sh
      rego: |
        package k8sallowedrepos

Copy link
Member

Choose a reason for hiding this comment

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

I don't see changes that address

IMO we should log and update status ONLY if code.engine is K8sNativeValidation.

This would require updating framework code I think. https://github.com/open-policy-agent/frameworks/blob/aa99306df54ee1e75380507503a547f22686b11d/constraint/pkg/client/drivers/k8scel/schema/schema.go#L291 to only return this error when code.engine == Name

This isnt blocking and can be added as a followup.

Signed-off-by: Jaydip Gabani <gabanijaydip@gmail.com>
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.

Project coverage is 48.03%. Comparing base (3350319) to head (e2a3a50).
Report is 125 commits behind head on master.

Files Patch % Lines
pkg/controller/constraint/constraint_controller.go 0.00% 6 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (3350319) and HEAD (e2a3a50). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (3350319) HEAD (e2a3a50)
unittests 2 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3493      +/-   ##
==========================================
- Coverage   54.49%   48.03%   -6.47%     
==========================================
  Files         134      219      +85     
  Lines       12329    15169    +2840     
==========================================
+ Hits         6719     7286     +567     
- Misses       5116     7069    +1953     
- Partials      494      814     +320     
Flag Coverage Δ
unittests 48.03% <14.28%> (-6.47%) ⬇️

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

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

Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@ritazh ritazh left a comment

Choose a reason for hiding this comment

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

LGTM

@JaydipGabani JaydipGabani merged commit 4eb7dcd into open-policy-agent:master Aug 14, 2024
19 checks passed
@JaydipGabani JaydipGabani deleted the cstr-error branch August 14, 2024 04:35
JaydipGabani added a commit to JaydipGabani/gatekeeper that referenced this pull request Aug 14, 2024
…ent#3493)

Signed-off-by: Jaydip Gabani <gabanijaydip@gmail.com>
(cherry picked from commit 4eb7dcd)
JaydipGabani added a commit to JaydipGabani/gatekeeper that referenced this pull request Aug 14, 2024
…ent#3493)

Signed-off-by: Jaydip Gabani <gabanijaydip@gmail.com>
(cherry picked from commit 4eb7dcd)
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.

constraint status error in 3.17.0-rc
4 participants