[VC-35738] Only start DataGatherer if its API resource is available #618
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The aim of this PR is to avoid triggering the warnings logged in client-go/tools/cache/reflector.go when a resource group version is not installed in the Kubernetes API server.
An example of such a warning, with
--logging-format=json:{"caller":"cache/reflector.go:561", "msg":"k8s.io/[email protected]/tools/cache/reflector.go:243: failed to list cas-issuer.jetstack.io/v1beta1, Resource=googlecasissuers: the server could not find the requested resource", "ts":1.7320377905120225E12, "v":0}It is easy enough to list the available APIs and only start the DataGatherers for available resource types,
but it's not easy to maintain the existing behaviour, which is to start collecting data for resources (CRDs) which are installed after the agent has been deployed.
And to stop reporting data for resource types which are removed from the API server after the agent has started.
This problem apparently also affects the kube-controller-manager, and is being discussed in kubernetes/kubernetes#79610
Among the comments of that issue, users are complaining about the volume of errors and warnings logged by the kube-controller-manager after a CRD is removed.
The venafi-kubernetes-agent already supresses the errors by installing a custom WatchErrorHandler, which turns the errors into V(1) info messages:
jetstack-secure/pkg/datagatherer/k8s/dynamic.go
Lines 269 to 294 in f644b84
I learned from the klog authors that there is an in progress PR which will remove this distracting warning message:
So the problem will likely be fixed by upgrading to the next or subsequent release of client-go.
Meanwhile we can advise users how to filter out the warnings in their log servers.
So I will close this PR.
Testing
TODO: