1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-28 18:38:40 +00:00

Do not generate preconditions not met warning for audit policies (#3487)

* Do not generate preconditions not met warning for audit policies

Signed-off-by: abhi-kapoor <43758739+abhi-kapoor@users.noreply.github.com>

* Update PR template to reeference the closing keyword

Signed-off-by: abhi-kapoor <43758739+abhi-kapoor@users.noreply.github.com>

* Update pkg/engine/validation.go

Co-authored-by: Prateek Pandey <prateekpandey14@gmail.com>

* Update pkg/engine/validation.go

Co-authored-by: Prateek Pandey <prateekpandey14@gmail.com>

Co-authored-by: Prateek Pandey <prateek.pandey@nirmata.com>
Co-authored-by: shuting <shutting06@gmail.com>
Co-authored-by: Prateek Pandey <prateekpandey14@gmail.com>
Co-authored-by: shuting <shuting@nirmata.com>
This commit is contained in:
Abhi Kapoor 2022-04-05 06:08:01 -04:00 committed by GitHub
parent f77220ad66
commit 18d4dadab6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -1,7 +1,7 @@
## Related issue
<!--
Please link the GitHub issue this pull request resolves in the format of `#1234`. If you discussed this change
Please link the GitHub issue this pull request resolves in the format of `Closes #1234`. If you discussed this change
with a maintainer, please mention her/him using the `@` syntax (e.g. `@JimBugwadia`).
If this change neither resolves an existing issue nor has sign-off from one of the maintainers, there is a

View file

@ -206,7 +206,7 @@ func (v *validator) validate() *response.RuleResponse {
return ruleError(v.rule, utils.Validation, "failed to evaluate preconditions", err)
}
if !preconditionsPassed {
if !preconditionsPassed && v.ctx.Policy.GetSpec().ValidationFailureAction != kyverno.Audit {
return ruleResponse(v.rule, utils.Validation, "preconditions not met", response.RuleStatusSkip)
}
@ -247,7 +247,7 @@ func (v *validator) validateForEach() *response.RuleResponse {
preconditionsPassed, err := checkPreconditions(v.log, v.ctx, v.anyAllConditions)
if err != nil {
return ruleError(v.rule, utils.Validation, "failed to evaluate preconditions", err)
} else if !preconditionsPassed {
} else if !preconditionsPassed && v.ctx.Policy.GetSpec().ValidationFailureAction != kyverno.Audit {
return ruleResponse(v.rule, utils.Validation, "preconditions not met", response.RuleStatusSkip)
}