Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

🐛 Ignore groups not served by the cluster #440

Merged
merged 2 commits into from
Jun 9, 2022

Conversation

jerr
Copy link
Contributor

@jerr jerr commented Jun 9, 2022

Description

If a group is not available on a server the discovery.ServerPreferredResources function returns the list of preferred resources but also an ErrGroupDiscoveryFailed error with the groups not available.

This error can be ignored because the unavailable resource types should not be audited.

This is an example of a cluster with the external.metrics.k8s.io group not available:

$ kubectl  get apiservice v1beta1.external.metrics.k8s.io 
NAME                              SERVICE                    AVAILABLE                      AGE
v1beta1.external.metrics.k8s.io   my-custom-metrics-server   False (FailedDiscoveryCheck)   22d
$ kubectl  get --raw /apis/external.metrics.k8s.io/v1beta1
Error from server (ServiceUnavailable): the server is currently unable to handle the request

If we have a cluster in this state no resources are audited because an error is returned by discovery.ServerPreferredResources

lists, err := kc.ServerPreferredResources()
if err == nil {

Type of change
  • Bug fix 🐛
How Has This Been Tested?
  • Automated tests still work
  • Manual tests: The kubeaudit all command was tested on a cluster with an unavailable external.metrics.k8s.io group. Without this fix no reports are displayed, with the fix the reports are provided as expected.
Checklist:
  • I have 🎩 my changes (A 🎩 specifically includes pulling down changes, setting them up, and manually testing the changed features and potential side effects to make sure nothing is broken)
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The test coverage did not decrease
  • I have signed the appropriate Contributor License Agreement

@jerr jerr marked this pull request as ready for review June 9, 2022 18:11
genevieveluyt
genevieveluyt previously approved these changes Jun 9, 2022
Copy link
Contributor

@genevieveluyt genevieveluyt left a comment

Choose a reason for hiding this comment

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

Thanks! Just an optional nit

internal/k8sinternal/client.go Outdated Show resolved Hide resolved
@genevieveluyt genevieveluyt merged commit 0ce511d into main Jun 9, 2022
@genevieveluyt genevieveluyt deleted the ignore_groups_not_served branch June 9, 2022 22:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants