mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Merge pull request #124557 from danwinship/metrics-and-stuff
kube-proxy metrics cleanup (and stuff)
This commit is contained in:
@@ -450,7 +450,7 @@ func CleanupLeftovers(ctx context.Context, ipt utiliptables.Interface) (encounte
|
||||
err = ipt.Restore(utiliptables.TableNAT, natLines, utiliptables.NoFlushTables, utiliptables.RestoreCounters)
|
||||
if err != nil {
|
||||
logger.Error(err, "Failed to execute iptables-restore", "table", utiliptables.TableNAT)
|
||||
metrics.IptablesRestoreFailuresTotal.Inc()
|
||||
metrics.IPTablesRestoreFailuresTotal.Inc()
|
||||
encounteredError = true
|
||||
}
|
||||
}
|
||||
@@ -477,7 +477,7 @@ func CleanupLeftovers(ctx context.Context, ipt utiliptables.Interface) (encounte
|
||||
// Write it.
|
||||
if err := ipt.Restore(utiliptables.TableFilter, filterLines, utiliptables.NoFlushTables, utiliptables.RestoreCounters); err != nil {
|
||||
logger.Error(err, "Failed to execute iptables-restore", "table", utiliptables.TableFilter)
|
||||
metrics.IptablesRestoreFailuresTotal.Inc()
|
||||
metrics.IPTablesRestoreFailuresTotal.Inc()
|
||||
encounteredError = true
|
||||
}
|
||||
}
|
||||
@@ -817,7 +817,7 @@ func (proxier *Proxier) syncProxyRules() {
|
||||
proxier.logger.Info("Sync failed", "retryingTime", proxier.syncPeriod)
|
||||
proxier.syncRunner.RetryAfter(proxier.syncPeriod)
|
||||
if tryPartialSync {
|
||||
metrics.IptablesPartialRestoreFailuresTotal.Inc()
|
||||
metrics.IPTablesPartialRestoreFailuresTotal.Inc()
|
||||
}
|
||||
// proxier.serviceChanges and proxier.endpointChanges have already
|
||||
// been flushed, so we've lost the state needed to be able to do
|
||||
@@ -1482,10 +1482,10 @@ func (proxier *Proxier) syncProxyRules() {
|
||||
"-j", "ACCEPT",
|
||||
)
|
||||
|
||||
metrics.IptablesRulesTotal.WithLabelValues(string(utiliptables.TableFilter)).Set(float64(proxier.filterRules.Lines()))
|
||||
metrics.IptablesRulesLastSync.WithLabelValues(string(utiliptables.TableFilter)).Set(float64(proxier.filterRules.Lines()))
|
||||
metrics.IptablesRulesTotal.WithLabelValues(string(utiliptables.TableNAT)).Set(float64(proxier.natRules.Lines() + skippedNatRules.Lines() - deletedChains))
|
||||
metrics.IptablesRulesLastSync.WithLabelValues(string(utiliptables.TableNAT)).Set(float64(proxier.natRules.Lines() - deletedChains))
|
||||
metrics.IPTablesRulesTotal.WithLabelValues(string(utiliptables.TableFilter)).Set(float64(proxier.filterRules.Lines()))
|
||||
metrics.IPTablesRulesLastSync.WithLabelValues(string(utiliptables.TableFilter)).Set(float64(proxier.filterRules.Lines()))
|
||||
metrics.IPTablesRulesTotal.WithLabelValues(string(utiliptables.TableNAT)).Set(float64(proxier.natRules.Lines() + skippedNatRules.Lines() - deletedChains))
|
||||
metrics.IPTablesRulesLastSync.WithLabelValues(string(utiliptables.TableNAT)).Set(float64(proxier.natRules.Lines() - deletedChains))
|
||||
|
||||
// Sync rules.
|
||||
proxier.iptablesData.Reset()
|
||||
@@ -1517,7 +1517,7 @@ func (proxier *Proxier) syncProxyRules() {
|
||||
} else {
|
||||
proxier.logger.Error(err, "Failed to execute iptables-restore")
|
||||
}
|
||||
metrics.IptablesRestoreFailuresTotal.Inc()
|
||||
metrics.IPTablesRestoreFailuresTotal.Inc()
|
||||
return
|
||||
}
|
||||
success = true
|
||||
|
||||
@@ -49,10 +49,10 @@ import (
|
||||
klogtesting "k8s.io/klog/v2/ktesting"
|
||||
"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/metrics"
|
||||
|
||||
"k8s.io/kubernetes/pkg/proxy/healthcheck"
|
||||
"k8s.io/kubernetes/pkg/proxy/metrics"
|
||||
proxyutil "k8s.io/kubernetes/pkg/proxy/util"
|
||||
proxyutiltest "k8s.io/kubernetes/pkg/proxy/util/testing"
|
||||
"k8s.io/kubernetes/pkg/util/async"
|
||||
@@ -408,7 +408,7 @@ func countRules(logger klog.Logger, tableName utiliptables.Table, ruleData strin
|
||||
}
|
||||
|
||||
func countRulesFromMetric(logger klog.Logger, tableName utiliptables.Table) int {
|
||||
numRulesFloat, err := testutil.GetGaugeMetricValue(metrics.IptablesRulesTotal.WithLabelValues(string(tableName)))
|
||||
numRulesFloat, err := testutil.GetGaugeMetricValue(metrics.IPTablesRulesTotal.WithLabelValues(string(tableName)))
|
||||
if err != nil {
|
||||
logger.Error(err, "metrics are not registered?")
|
||||
return -1
|
||||
@@ -417,7 +417,7 @@ func countRulesFromMetric(logger klog.Logger, tableName utiliptables.Table) int
|
||||
}
|
||||
|
||||
func countRulesFromLastSyncMetric(logger klog.Logger, tableName utiliptables.Table) int {
|
||||
numRulesFloat, err := testutil.GetGaugeMetricValue(metrics.IptablesRulesLastSync.WithLabelValues(string(tableName)))
|
||||
numRulesFloat, err := testutil.GetGaugeMetricValue(metrics.IPTablesRulesLastSync.WithLabelValues(string(tableName)))
|
||||
if err != nil {
|
||||
logger.Error(err, "metrics are not registered?")
|
||||
return -1
|
||||
@@ -1543,7 +1543,7 @@ func TestOverallIPTablesRules(t *testing.T) {
|
||||
logger, _ := klogtesting.NewTestContext(t)
|
||||
ipt := iptablestest.NewFake()
|
||||
fp := NewFakeProxier(ipt)
|
||||
metrics.RegisterMetrics()
|
||||
metrics.RegisterMetrics(kubeproxyconfig.ProxyModeIPTables)
|
||||
|
||||
makeServiceMap(fp,
|
||||
// create ClusterIP service
|
||||
@@ -4142,12 +4142,12 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestProxierMetricsIptablesTotalRules(t *testing.T) {
|
||||
func TestProxierMetricsIPTablesTotalRules(t *testing.T) {
|
||||
logger, _ := klogtesting.NewTestContext(t)
|
||||
ipt := iptablestest.NewFake()
|
||||
fp := NewFakeProxier(ipt)
|
||||
|
||||
metrics.RegisterMetrics()
|
||||
metrics.RegisterMetrics(kubeproxyconfig.ProxyModeIPTables)
|
||||
|
||||
svcIP := "172.30.0.41"
|
||||
svcPort := 80
|
||||
@@ -5827,7 +5827,7 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
|
||||
logger, _ := klogtesting.NewTestContext(t)
|
||||
ipt := iptablestest.NewFake()
|
||||
fp := NewFakeProxier(ipt)
|
||||
metrics.RegisterMetrics()
|
||||
metrics.RegisterMetrics(kubeproxyconfig.ProxyModeIPTables)
|
||||
defer legacyregistry.Reset()
|
||||
|
||||
// Create initial state
|
||||
@@ -6356,7 +6356,7 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
|
||||
if fp.needFullSync {
|
||||
t.Fatalf("Proxier unexpectedly already needs a full sync?")
|
||||
}
|
||||
partialRestoreFailures, err := testutil.GetCounterMetricValue(metrics.IptablesPartialRestoreFailuresTotal)
|
||||
partialRestoreFailures, err := testutil.GetCounterMetricValue(metrics.IPTablesPartialRestoreFailuresTotal)
|
||||
if err != nil {
|
||||
t.Fatalf("Could not get partial restore failures metric: %v", err)
|
||||
}
|
||||
@@ -6390,7 +6390,7 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
|
||||
if !fp.needFullSync {
|
||||
t.Errorf("Proxier did not fail on previous partial resync?")
|
||||
}
|
||||
updatedPartialRestoreFailures, err := testutil.GetCounterMetricValue(metrics.IptablesPartialRestoreFailuresTotal)
|
||||
updatedPartialRestoreFailures, err := testutil.GetCounterMetricValue(metrics.IPTablesPartialRestoreFailuresTotal)
|
||||
if err != nil {
|
||||
t.Errorf("Could not get partial restore failures metric: %v", err)
|
||||
}
|
||||
@@ -6471,7 +6471,7 @@ func TestNoEndpointsMetric(t *testing.T) {
|
||||
hostname string
|
||||
}
|
||||
|
||||
metrics.RegisterMetrics()
|
||||
metrics.RegisterMetrics(kubeproxyconfig.ProxyModeIPTables)
|
||||
testCases := []struct {
|
||||
name string
|
||||
internalTrafficPolicy *v1.ServiceInternalTrafficPolicy
|
||||
|
||||
Reference in New Issue
Block a user