Merge pull request #124557 from danwinship/metrics-and-stuff

kube-proxy metrics cleanup (and stuff)
This commit is contained in:
Kubernetes Prow Robot
2024-04-26 18:31:57 -07:00
committed by GitHub
13 changed files with 114 additions and 89 deletions

View File

@@ -1032,7 +1032,7 @@ func (proxier *Proxier) syncProxyRules() {
// the chains still exist, they'll just get added back
// (with a later timestamp) at the end of the sync.
proxier.logger.Error(err, "Unable to delete stale chains; will retry later")
// FIXME: metric
metrics.NFTablesCleanupFailuresTotal.Inc()
}
}
}
@@ -1613,13 +1613,18 @@ func (proxier *Proxier) syncProxyRules() {
"numEndpoints", totalEndpoints,
)
// FIXME
// klog.V(9).InfoS("Running nftables transaction", "transaction", tx.Bytes())
if klogV9 := klog.V(9); klogV9.Enabled() {
klogV9.InfoS("Running nftables transaction", "transaction", tx.String())
}
err = proxier.nftables.Run(context.TODO(), tx)
if err != nil {
proxier.logger.Error(err, "nftables sync failed")
metrics.IptablesRestoreFailuresTotal.Inc()
metrics.NFTablesSyncFailuresTotal.Inc()
// staleChains is now incorrect since we didn't actually flush the
// chains in it. We can recompute it next time.
clear(proxier.staleChains)
return
}
success = true

View File

@@ -40,6 +40,7 @@ import (
"k8s.io/component-base/metrics/testutil"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/proxy"
kubeproxyconfig "k8s.io/kubernetes/pkg/proxy/apis/config"
"k8s.io/kubernetes/pkg/proxy/conntrack"
"k8s.io/kubernetes/pkg/proxy/healthcheck"
"k8s.io/kubernetes/pkg/proxy/metrics"
@@ -140,7 +141,7 @@ func NewFakeProxier(ipFamily v1.IPFamily) (*knftables.Fake, *Proxier) {
// rules are exactly as expected.
func TestOverallNFTablesRules(t *testing.T) {
nft, fp := NewFakeProxier(v1.IPv4Protocol)
metrics.RegisterMetrics()
metrics.RegisterMetrics(kubeproxyconfig.ProxyModeNFTables)
makeServiceMap(fp,
// create ClusterIP service
@@ -4454,7 +4455,7 @@ func TestNoEndpointsMetric(t *testing.T) {
hostname string
}
metrics.RegisterMetrics()
metrics.RegisterMetrics(kubeproxyconfig.ProxyModeNFTables)
testCases := []struct {
name string
internalTrafficPolicy *v1.ServiceInternalTrafficPolicy