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

feat: Add OpenShift exceptions #311

Merged
merged 5 commits into from
Jun 18, 2024
Merged

Conversation

doronkg
Copy link
Contributor

@doronkg doronkg commented Jun 18, 2024

What this PR does / why we need it

This PR excludes the default resources created in basic OpenShift installations.
In addition, I've moved the config load out of the processing loop in most resource types, to reduce excessive iterations.

PR Checklist

  • This PR adds K8s exceptions (false positives)
  • This PR adds new code
  • This PR includes test for any new code

GitHub Issue

Closes #240

Notes for your reviewers

In pkg/kor/secrets.go, a new exception secret type was added - kubernetes.io/dockercfg, which is the OpenShift equivalent of kubernetes.io/dockerconfigjson.

Basic OpenShift installation comes with 60+ namespaces beginning with openshift- prefix, which doesn't include additional namespaces created by OpenShift operators or customized installations, that would also be created with that prefix.
For that case, I've excluded all openshift- namespaces in all relevant namespaced resource types, with the following pattern:

    {
      "Namespace": "openshift-.*",
      "ResourceName": ".*",
      "MatchRegex": true
    }

@codecov-commenter
Copy link

codecov-commenter commented Jun 18, 2024

Codecov Report

Attention: Patch coverage is 27.02703% with 27 lines in your changes missing coverage. Please review.

Project coverage is 41.30%. Comparing base (a2f3629) to head (92d3283).

Files Patch % Lines
pkg/kor/pdbs.go 25.00% 3 Missing and 3 partials ⚠️
pkg/kor/replicaset.go 25.00% 3 Missing and 3 partials ⚠️
pkg/kor/crds.go 0.00% 3 Missing ⚠️
pkg/kor/clusterroles.go 33.33% 1 Missing and 1 partial ⚠️
pkg/kor/daemonsets.go 33.33% 1 Missing and 1 partial ⚠️
pkg/kor/roles.go 33.33% 1 Missing and 1 partial ⚠️
pkg/kor/secrets.go 33.33% 1 Missing and 1 partial ⚠️
pkg/kor/services.go 33.33% 1 Missing and 1 partial ⚠️
pkg/kor/storageclasses.go 33.33% 1 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #311      +/-   ##
==========================================
- Coverage   41.38%   41.30%   -0.09%     
==========================================
  Files          61       61              
  Lines        3204     3220      +16     
==========================================
+ Hits         1326     1330       +4     
- Misses       1668     1674       +6     
- Partials      210      216       +6     

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

Copy link
Owner

@yonahd yonahd left a comment

Choose a reason for hiding this comment

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

Couple small comments

pkg/kor/exceptions/replicasets/replicasets.json Outdated Show resolved Hide resolved
pkg/kor/exceptions/pdbs/pdbs.json Show resolved Hide resolved
Copy link
Owner

@yonahd yonahd left a comment

Choose a reason for hiding this comment

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

Lgtm

@yonahd yonahd merged commit ced2ef2 into yonahd:main Jun 18, 2024
2 checks passed
@doronkg doronkg deleted the feat_openshift_exceptions branch June 18, 2024 18:44
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.

Map false unused resources: Openshift
3 participants