mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-15 17:51:20 +00:00
3bf3dcc1af
* Add metric "kyverno_kube_client_queries_total" Signed-off-by: ShutingZhao <shuting@nirmata.com> * publish metric for missing queries Signed-off-by: ShutingZhao <shuting@nirmata.com> * Refactor the way Kyverno registers QPS metric Signed-off-by: ShutingZhao <shuting@nirmata.com> * Move clientsets to a dedicated folder Signed-off-by: ShutingZhao <shuting@nirmata.com> * Wrap Kyverno client and policyreport client to register client query metric Signed-off-by: ShutingZhao <shuting@nirmata.com> * address linter comments Signed-off-by: ShutingZhao <shuting@nirmata.com> * address linter comments Signed-off-by: ShutingZhao <shuting@nirmata.com> * Switch to use wrapper clients Signed-off-by: ShutingZhao <shuting@nirmata.com> Signed-off-by: ShutingZhao <shuting@nirmata.com> Co-authored-by: Vyankatesh Kudtarkar <vyankateshkd@gmail.com>
27 lines
1,013 B
Go
27 lines
1,013 B
Go
package dclient
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"k8s.io/client-go/discovery"
|
|
)
|
|
|
|
func logDiscoveryErrors(err error, c serverPreferredResources) {
|
|
discoveryError := err.(*discovery.ErrGroupDiscoveryFailed)
|
|
for gv, e := range discoveryError.Groups {
|
|
if gv.Group == "custom.metrics.k8s.io" || gv.Group == "metrics.k8s.io" || gv.Group == "external.metrics.k8s.io" {
|
|
// These errors occur when Prometheus is installed as an external metrics server
|
|
// See: https://github.com/kyverno/kyverno/issues/1490
|
|
logger.V(3).Info("failed to retrieve metrics API group", "gv", gv)
|
|
continue
|
|
}
|
|
logger.Error(e, "failed to retrieve API group", "gv", gv)
|
|
}
|
|
}
|
|
|
|
func isMetricsServerUnavailable(kind string, err error) bool {
|
|
// error message is defined at:
|
|
// https://github.com/kubernetes/apimachinery/blob/2456ebdaba229616fab2161a615148884b46644b/pkg/api/errors/errors.go#L432
|
|
return strings.HasPrefix(kind, "metrics.k8s.io/") &&
|
|
strings.Contains(err.Error(), "the server is currently unable to handle the request")
|
|
}
|