kyverno: [Bug] [CLI] kyverno test are applying previous mutation rules to subsequent test cases causing failures
Kyverno CLI Version
1.9.2
Description
If you have 2 rules in the same policy that start with the same string, it seems to process the policy twice if both are specfied in the same kyverno-test.yaml file.
I am unsure if this is supposed to be a feature or some oversight, but it was very hard to debug. Seems like if you are specifying the rule to be tested, other rules should not be applied.
Steps to reproduce
name: policy-test
policies:
- my-policy.yaml
resources:
- resource.yaml
results:
- policy: my-policy
rule: foo-rule
resource: resource-1
patchedResource: patched-resource-1.yaml
kind: Pod
result: pass
- policy: my-policy
rule: foo-rule-bar # same prefix as foo-rule
resource: resource-1
kind: Pod
result: skip
The second rule will fail because for some reason since foo-rule-bar starts with foo-rule it also applies the first result rule to resource-2. If you remove the first result rule, it passes.
Expected behavior
Rule names in prior results should not affect the results of later results if the prior rule is a substring of the current rule.
Screenshots
No response
Kyverno logs
No response
Slack discussion
No response
Troubleshooting
- I have read and followed the troubleshooting guide.
- I have searched other issues in this repository and mine is not recorded.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 19 (18 by maintainers)
By all policies, do you mean all rules in a policy (I agree this makes more sense)?
If so, then shouldn’t the rule field be removed entirely?