Skip to content

Conversation

MariamFahmy98
Copy link
Contributor

@MariamFahmy98 MariamFahmy98 commented Nov 27, 2023

Explanation

This PR adds a post-upgrade helm hook to remove the older policy reports; PolicyReports and ClusterPolicyReports contain pol in their name.

Related issue

Closes #8918

Milestone of this PR

/milestone 1.11.1

What type of PR is this

/kind bug

Proposed Changes

Adding a post-upgrade hook to be executed after all resources have been upgraded.

Proof Manifests

  1. Install Kyverno 1.10
  2. Create some policies and resources to get policy reports.
  3. Get all policy reports:
$ kubectl get policyreports.wgpolicyk8s.io -A
NAMESPACE            NAME                            PASS   FAIL   WARN   ERROR   SKIP   AGE
default              cpol-disallow-host-namespaces   3      3      0      0       0      2m9s
default              pol-validate-1                  0      2      0      0       0      2m9s
kube-system          cpol-disallow-host-namespaces   4      14     0      0       0      2m10s
kyverno              cpol-disallow-host-namespaces   18     0      0      0       0      2m10s
local-path-storage   cpol-disallow-host-namespaces   3      0      0      0       0      2m9s

$ kubectl get clusterpolicyreports.wgpolicyk8s.io 
NAME                            PASS   FAIL   WARN   ERROR   SKIP   AGE
cpol-require-ns-purpose-label   0      7      0      0       0      3m30s
  1. Upgrade to 1.11
  2. Get jobs:
$ kubectl get jobs.batch -n kyverno 
NAME                                                 COMPLETIONS   DURATION   AGE
kyverno-cleanup-admission-reports-28352740           1/1           59s        7m39s
kyverno-cleanup-cluster-admission-reports-28352740   1/1           59s        7m39s
kyverno-hook-post-upgrade                            0/1           19s        19s
  1. Get all policy reports:
$ kubectl get policyreports.wgpolicyk8s.io
NAME                                   PASS   FAIL   WARN   ERROR   SKIP   AGE
0d1f6d48-ba53-4252-8472-ea279d339d4f   0      2      0      0       0      75s
1168b3d1-611a-4558-80d0-d98f0baa4254   1      0      0      0       0      75s
387bd3cd-d4d3-4dd1-95f8-830871516c59   0      1      0      0       0      75s
63246c12-fc56-41d0-823b-bbe3e52bc20d   0      1      0      0       0      75s
d2b871cf-07fa-41c4-aba1-cbc7e38d1d26   1      1      0      0       0      75s
d6800030-445f-4a84-9e76-9c139a90e884   1      0      0      0       0      75s

$ kubectl get clusterpolicyreports.wgpolicyk8s.io 
NAME                                   PASS   FAIL   WARN   ERROR   SKIP   AGE
1d3a1a72-8202-4b98-9214-c5f3aa4bfa94   0      1      0      0       0      85s
3d0da106-bf24-4bd4-908f-af92fe46e6e6   0      1      0      0       0      85s
5f5ae0eb-a1b9-47a3-b117-8ae656f699a1   0      1      0      0       0      85s
6759b55f-113c-4b7f-b0ca-3106d8230811   0      1      0      0       0      85s
a52327ec-c760-4d23-80d1-0795f262fdfc   0      1      0      0       0      85s
bf65d2cc-9e7d-4c54-8c20-0a29d0f9fef8   0      1      0      0       0      85s
f3e31047-4339-46df-b11b-f1e7f0a445af   0      1      0      0       0      85s

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.
  • This is a feature and I have added CLI tests that are applicable.
  • My PR needs to be cherry picked to a specific release branch which is .
  • My PR contains new or altered behavior to Kyverno and
    • CLI support should be added and my PR doesn't contain that functionality.
    • I have added or changed the documentation myself in an existing PR and the link is:
    • I have raised an issue in kyverno/website to track the documentation update and the link is:

Further Comments

Copy link

codecov bot commented Nov 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (85a5816) 33.54% compared to head (6609af8) 33.54%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9026   +/-   ##
=======================================
  Coverage   33.54%   33.54%           
=======================================
  Files         314      314           
  Lines       24925    24925           
=======================================
  Hits         8362     8362           
  Misses      15767    15767           
  Partials      796      796           

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

@MariamFahmy98 MariamFahmy98 force-pushed the fix-8918 branch 4 times, most recently from a71e606 to 514cede Compare November 27, 2023 13:12
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
@realshuting realshuting enabled auto-merge (squash) November 28, 2023 10:01
@realshuting
Copy link
Member

/cherry-pick release-1.11

@realshuting realshuting merged commit cb80329 into kyverno:main Nov 28, 2023
gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Nov 28, 2023
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
@MariamFahmy98 MariamFahmy98 deleted the fix-8918 branch November 28, 2023 10:59
@realshuting realshuting added the cherry-pick-completed The PR was cherry-picked (or merged) to required release branches label Nov 28, 2023
realshuting pushed a commit that referenced this pull request Nov 28, 2023
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
Co-authored-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
vishal-chdhry pushed a commit to vishal-chdhry/kyverno that referenced this pull request Jan 5, 2024
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
vishal-chdhry pushed a commit to vishal-chdhry/kyverno that referenced this pull request Jan 5, 2024
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
vishal-chdhry pushed a commit to vishal-chdhry/kyverno that referenced this pull request Jan 6, 2024
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-completed The PR was cherry-picked (or merged) to required release branches cherry-pick-required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] cleanup older policy reports
2 participants