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

chore: adding common function for error reporting for constraint #3486

Merged

Conversation

JaydipGabani
Copy link
Contributor

@JaydipGabani JaydipGabani commented Aug 12, 2024

What this PR does / why we need it:

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

Special notes for your reviewer:
Here is how the constraint status looks after this change -

status:
    byPod:
    - constraintUID: d50a2340-d4de-4bfd-8cb7-5ecbd645e9b1
      enforced: true
      errors:
      - code: ""
        message: 'cannot generate ValidatingAdmissionPolicyBinding: ValidatingAdmissionPolicy
          API is not enabled'
      id: gatekeeper-audit-78dd48444d-9k6h7
      observedGeneration: 1
      operations:
      - audit
      - mutation-status
      - status
    - constraintUID: d50a2340-d4de-4bfd-8cb7-5ecbd645e9b1
      enforced: true
      errors:
      - code: ""
        message: 'cannot generate ValidatingAdmissionPolicyBinding: ValidatingAdmissionPolicy
          API is not enabled'
      id: gatekeeper-controller-manager-c86c8b5-2g7pn
      observedGeneration: 1
      operations:
      - mutation-webhook
      - webhook
    - constraintUID: d50a2340-d4de-4bfd-8cb7-5ecbd645e9b1
      enforced: true
      errors:
      - code: ""
        message: 'cannot generate ValidatingAdmissionPolicyBinding: ValidatingAdmissionPolicy
          API is not enabled'
      id: gatekeeper-controller-manager-c86c8b5-k9sxf
      observedGeneration: 1
      operations:
      - mutation-webhook
      - webhook
    - constraintUID: d50a2340-d4de-4bfd-8cb7-5ecbd645e9b1
      enforced: true
      errors:
      - code: ""
        message: 'cannot generate ValidatingAdmissionPolicyBinding: ValidatingAdmissionPolicy
          API is not enabled'
      id: gatekeeper-controller-manager-c86c8b5-zx89k
      observedGeneration: 1
      operations:
      - mutation-webhook
      - webhook

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

codecov-commenter commented Aug 12, 2024

Codecov Report

Attention: Patch coverage is 28.57143% with 15 lines in your changes missing coverage. Please review.

Project coverage is 48.16%. Comparing base (3350319) to head (f751249).
Report is 148 commits behind head on master.

Files with missing lines Patch % Lines
pkg/controller/constraint/constraint_controller.go 28.57% 15 Missing ⚠️

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

HEAD has 1 upload less than BASE
Flag BASE (3350319) HEAD (f751249)
unittests 2 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3486      +/-   ##
==========================================
- Coverage   54.49%   48.16%   -6.33%     
==========================================
  Files         134      218      +84     
  Lines       12329    15134    +2805     
==========================================
+ Hits         6719     7290     +571     
- Misses       5116     7029    +1913     
- Partials      494      815     +321     
Flag Coverage Δ
unittests 48.16% <28.57%> (-6.33%) ⬇️

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.

@JaydipGabani JaydipGabani marked this pull request as ready for review September 17, 2024 03:51
@JaydipGabani JaydipGabani requested a review from a team as a code owner September 17, 2024 03:51
@JaydipGabani JaydipGabani changed the title [WIP] chore: adding common function for error reporting for constraint chore: adding common function for error reporting for constraint Sep 17, 2024
if err2 := r.writer.Update(ctx, status); err2 != nil {
log.Error(err2, "could not report constraint error status")
}
reportMetrics = true
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens to the reportMetrics flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the flag back. This was not supposed to be removed. Good catch!

Signed-off-by: Jaydip Gabani <gabanijaydip@gmail.com>
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 07127f2 into open-policy-agent:master Sep 19, 2024
19 checks passed
@JaydipGabani JaydipGabani deleted the report-constraint-error branch September 19, 2024 18:22
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.

Common function to report errors on constraint.status
4 participants