Skip to content

feat: Add validationActions field type to PolicyException to override vpol failureAction#85

Open
onasser1 wants to merge 2 commits into
kyverno:mainfrom
onasser1:allow-vpol-override
Open

feat: Add validationActions field type to PolicyException to override vpol failureAction#85
onasser1 wants to merge 2 commits into
kyverno:mainfrom
onasser1:allow-vpol-override

Conversation

@onasser1
Copy link
Copy Markdown
Contributor

@onasser1 onasser1 commented Apr 30, 2026

Explanation

We need to support override for ValidatingPolicy failureAction in PolicyException so in order to do that we need to define the validationActions field first in PolicyException API

Related issue

Needed for / Part of: kyverno/kyverno#14927

Proposed Changes

  • Add validationActions field to PolicyException

Checklist

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.

Further Comments

@realshuting
Copy link
Copy Markdown
Member

Why do we need this?

@realshuting
Copy link
Copy Markdown
Member

The original issue is to add this field in policyexception to override the failure action.

@onasser1
Copy link
Copy Markdown
Contributor Author

The original issue is to add this field in policyexception to override the failure action.

@realshuting I think I misunderstood this, I thought about introducing an override for validationActions

@onasser1 onasser1 force-pushed the allow-vpol-override branch 2 times, most recently from f495ee2 to e788b66 Compare May 1, 2026 02:55
…ure action

Signed-off-by: Omar Nasser <omarnasserjr@gmail.com>
@onasser1 onasser1 changed the title feat: Add ValidationActionsOverride field type to ValidatingPolicy feat: Add validationActions field type to PolicyException to override vpol failureAction May 1, 2026
@onasser1
Copy link
Copy Markdown
Contributor Author

onasser1 commented May 1, 2026

The original issue is to add this field in policyexception to override the failure action.

@realshuting I made changes and updated the PR title and description


// ValidationActions overrides the policy's validation actions when set
// +optional
ValidationActions []admissionregistrationv1.ValidationAction `json:"validationActions,omitempty"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How can we specify per-policy-level validation actions override?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@realshuting you mean to have an override value for each policy reference?
so for each defined policy reference should have its own validation actions override? and if does not exist, apply the original policy's action.

Is this what you mean?

Copy link
Copy Markdown
Contributor Author

@onasser1 onasser1 May 1, 2026

Choose a reason for hiding this comment

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

Is this what you mean?

If yes, I think moving this into the PolicyRef type would be sufficient?
#85 (comment)

Comment on lines 70 to 76
type PolicyRef struct {
// Name is the name of the policy
Name string `json:"name"`

// Kind is the kind of the policy
Kind string `json:"kind"`
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
type PolicyRef struct {
// Name is the name of the policy
Name string `json:"name"`
// Kind is the kind of the policy
Kind string `json:"kind"`
// ValidationActions overrides the policy's validation actions when set
// +optional
ValidationActions []admissionregistrationv1.ValidationAction `json:"validationActions,omitempty"`
}

Signed-off-by: Omar Nasser <omarnasserjr@gmail.com>

// ValidationActions overrides the policy's validation actions when set
// +optional
ValidationActions []admissionregistrationv1.ValidationAction `json:"validationActions,omitempty"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need a list of actions?

@realshuting
Copy link
Copy Markdown
Member

Please resolve all comments once addressed.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the PolicyException API to support overriding a referenced policy’s validationActions, enabling per-exception control over ValidatingPolicy enforcement behavior.

Changes:

  • Added validationActions to PolicyRef in the PolicyException API (Go types + deepcopy support).
  • Updated generated CRD manifests (raw + aggregated + Helm chart template) to expose the new field.
  • Updated generated CRD documentation HTML to include the new field.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
docs/user/crd/kyverno_cel_policies.v1alpha1.html Generated CRD docs updated to document validationActions on PolicyRef.
docs/user/crd/index.html Generated CRD index updated to include validationActions in PolicyRef.
config/crds/policies.kyverno.io_policyexceptions.yaml PolicyException CRD schema updated to include policyRefs[].validationActions (multiple version blocks).
config/crds.yaml Aggregated CRDs updated to include policyRefs[].validationActions (multiple version blocks).
charts/kyverno-api/templates/crds/policies.kyverno.io_policyexceptions.yaml Helm CRD template updated to include policyRefs[].validationActions (multiple version blocks).
api/policies.kyverno.io/v1alpha1/zz_generated.deepcopy.go Deepcopy generation updated to deep-copy PolicyRef elements due to the new slice field.
api/policies.kyverno.io/v1alpha1/policy_exception.go Added validationActions field to PolicyRef.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Kind string `json:"kind"`

// ValidationActions overrides the policy's validation actions when set
// +optional
Comment on lines +73 to +75
// ValidationActions overrides the policy's validation actions when set
// +optional
ValidationActions []admissionregistrationv1.ValidationAction `json:"validationActions,omitempty"`
Comment on lines +117 to +119
action.
type: string
type: array
Comment thread config/crds.yaml
Comment on lines +31724 to +31731
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +119 to +121
action.
type: string
type: array
Comment on lines +368 to +370
action.
type: string
type: array
Comment thread config/crds.yaml
Comment on lines +31850 to +31857
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment thread config/crds.yaml
Comment on lines +31975 to +31982
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +245 to +247
action.
type: string
type: array
Comment on lines +370 to +372
action.
type: string
type: array
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.

3 participants