fix "Iptables" -> "IPTables" in metrics variable names

This commit is contained in:
Dan Winship 2023-12-25 10:01:02 -05:00
parent ba57fd7c84
commit 1823de063b
5 changed files with 29 additions and 29 deletions

View File

@ -451,7 +451,7 @@ func CleanupLeftovers(ctx context.Context, ipt utiliptables.Interface) (encounte
err = ipt.Restore(utiliptables.TableNAT, natLines, utiliptables.NoFlushTables, utiliptables.RestoreCounters) err = ipt.Restore(utiliptables.TableNAT, natLines, utiliptables.NoFlushTables, utiliptables.RestoreCounters)
if err != nil { if err != nil {
logger.Error(err, "Failed to execute iptables-restore", "table", utiliptables.TableNAT) logger.Error(err, "Failed to execute iptables-restore", "table", utiliptables.TableNAT)
metrics.IptablesRestoreFailuresTotal.Inc() metrics.IPTablesRestoreFailuresTotal.Inc()
encounteredError = true encounteredError = true
} }
} }
@ -478,7 +478,7 @@ func CleanupLeftovers(ctx context.Context, ipt utiliptables.Interface) (encounte
// Write it. // Write it.
if err := ipt.Restore(utiliptables.TableFilter, filterLines, utiliptables.NoFlushTables, utiliptables.RestoreCounters); err != nil { if err := ipt.Restore(utiliptables.TableFilter, filterLines, utiliptables.NoFlushTables, utiliptables.RestoreCounters); err != nil {
logger.Error(err, "Failed to execute iptables-restore", "table", utiliptables.TableFilter) logger.Error(err, "Failed to execute iptables-restore", "table", utiliptables.TableFilter)
metrics.IptablesRestoreFailuresTotal.Inc() metrics.IPTablesRestoreFailuresTotal.Inc()
encounteredError = true encounteredError = true
} }
} }
@ -818,7 +818,7 @@ func (proxier *Proxier) syncProxyRules() {
proxier.logger.Info("Sync failed", "retryingTime", proxier.syncPeriod) proxier.logger.Info("Sync failed", "retryingTime", proxier.syncPeriod)
proxier.syncRunner.RetryAfter(proxier.syncPeriod) proxier.syncRunner.RetryAfter(proxier.syncPeriod)
if tryPartialSync { if tryPartialSync {
metrics.IptablesPartialRestoreFailuresTotal.Inc() metrics.IPTablesPartialRestoreFailuresTotal.Inc()
} }
// proxier.serviceChanges and proxier.endpointChanges have already // proxier.serviceChanges and proxier.endpointChanges have already
// been flushed, so we've lost the state needed to be able to do // been flushed, so we've lost the state needed to be able to do
@ -1483,10 +1483,10 @@ func (proxier *Proxier) syncProxyRules() {
"-j", "ACCEPT", "-j", "ACCEPT",
) )
metrics.IptablesRulesTotal.WithLabelValues(string(utiliptables.TableFilter)).Set(float64(proxier.filterRules.Lines())) metrics.IPTablesRulesTotal.WithLabelValues(string(utiliptables.TableFilter)).Set(float64(proxier.filterRules.Lines()))
metrics.IptablesRulesLastSync.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.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.IPTablesRulesLastSync.WithLabelValues(string(utiliptables.TableNAT)).Set(float64(proxier.natRules.Lines() - deletedChains))
// Sync rules. // Sync rules.
proxier.iptablesData.Reset() proxier.iptablesData.Reset()
@ -1518,7 +1518,7 @@ func (proxier *Proxier) syncProxyRules() {
} else { } else {
proxier.logger.Error(err, "Failed to execute iptables-restore") proxier.logger.Error(err, "Failed to execute iptables-restore")
} }
metrics.IptablesRestoreFailuresTotal.Inc() metrics.IPTablesRestoreFailuresTotal.Inc()
return return
} }
success = true success = true

View File

@ -409,7 +409,7 @@ func countRules(logger klog.Logger, tableName utiliptables.Table, ruleData strin
} }
func countRulesFromMetric(logger klog.Logger, tableName utiliptables.Table) int { 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 { if err != nil {
logger.Error(err, "metrics are not registered?") logger.Error(err, "metrics are not registered?")
return -1 return -1
@ -418,7 +418,7 @@ func countRulesFromMetric(logger klog.Logger, tableName utiliptables.Table) int
} }
func countRulesFromLastSyncMetric(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 { if err != nil {
logger.Error(err, "metrics are not registered?") logger.Error(err, "metrics are not registered?")
return -1 return -1
@ -4143,7 +4143,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) {
} }
} }
func TestProxierMetricsIptablesTotalRules(t *testing.T) { func TestProxierMetricsIPTablesTotalRules(t *testing.T) {
logger, _ := klogtesting.NewTestContext(t) logger, _ := klogtesting.NewTestContext(t)
ipt := iptablestest.NewFake() ipt := iptablestest.NewFake()
fp := NewFakeProxier(ipt) fp := NewFakeProxier(ipt)
@ -6357,7 +6357,7 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
if fp.needFullSync { if fp.needFullSync {
t.Fatalf("Proxier unexpectedly already needs a full sync?") t.Fatalf("Proxier unexpectedly already needs a full sync?")
} }
partialRestoreFailures, err := testutil.GetCounterMetricValue(metrics.IptablesPartialRestoreFailuresTotal) partialRestoreFailures, err := testutil.GetCounterMetricValue(metrics.IPTablesPartialRestoreFailuresTotal)
if err != nil { if err != nil {
t.Fatalf("Could not get partial restore failures metric: %v", err) t.Fatalf("Could not get partial restore failures metric: %v", err)
} }
@ -6391,7 +6391,7 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
if !fp.needFullSync { if !fp.needFullSync {
t.Errorf("Proxier did not fail on previous partial resync?") 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 { if err != nil {
t.Errorf("Could not get partial restore failures metric: %v", err) t.Errorf("Could not get partial restore failures metric: %v", err)
} }

View File

@ -1445,7 +1445,7 @@ func (proxier *Proxier) syncProxyRules() {
} else { } else {
proxier.logger.Error(err, "Failed to execute iptables-restore", "rules", proxier.iptablesData.Bytes()) proxier.logger.Error(err, "Failed to execute iptables-restore", "rules", proxier.iptablesData.Bytes())
} }
metrics.IptablesRestoreFailuresTotal.Inc() metrics.IPTablesRestoreFailuresTotal.Inc()
return return
} }
for name, lastChangeTriggerTimes := range endpointUpdateResult.LastChangeTriggerTimes { for name, lastChangeTriggerTimes := range endpointUpdateResult.LastChangeTriggerTimes {

View File

@ -139,9 +139,9 @@ var (
}, },
) )
// IptablesRestoreFailuresTotal is the number of iptables restore failures that the proxy has // IPTablesRestoreFailuresTotal is the number of iptables restore failures that the proxy has
// seen. // seen.
IptablesRestoreFailuresTotal = metrics.NewCounter( IPTablesRestoreFailuresTotal = metrics.NewCounter(
&metrics.CounterOpts{ &metrics.CounterOpts{
Subsystem: kubeProxySubsystem, Subsystem: kubeProxySubsystem,
Name: "sync_proxy_rules_iptables_restore_failures_total", Name: "sync_proxy_rules_iptables_restore_failures_total",
@ -150,9 +150,9 @@ var (
}, },
) )
// IptablesPartialRestoreFailuresTotal is the number of iptables *partial* restore // IPTablesPartialRestoreFailuresTotal is the number of iptables *partial* restore
// failures (resulting in a fall back to a full restore) that the proxy has seen. // failures (resulting in a fall back to a full restore) that the proxy has seen.
IptablesPartialRestoreFailuresTotal = metrics.NewCounter( IPTablesPartialRestoreFailuresTotal = metrics.NewCounter(
&metrics.CounterOpts{ &metrics.CounterOpts{
Subsystem: kubeProxySubsystem, Subsystem: kubeProxySubsystem,
Name: "sync_proxy_rules_iptables_partial_restore_failures_total", Name: "sync_proxy_rules_iptables_partial_restore_failures_total",
@ -161,9 +161,9 @@ var (
}, },
) )
// IptablesRulesTotal is the total number of iptables rules that the iptables // IPTablesRulesTotal is the total number of iptables rules that the iptables
// proxy has installed. // proxy has installed.
IptablesRulesTotal = metrics.NewGaugeVec( IPTablesRulesTotal = metrics.NewGaugeVec(
&metrics.GaugeOpts{ &metrics.GaugeOpts{
Subsystem: kubeProxySubsystem, Subsystem: kubeProxySubsystem,
Name: "sync_proxy_rules_iptables_total", Name: "sync_proxy_rules_iptables_total",
@ -173,9 +173,9 @@ var (
[]string{"table"}, []string{"table"},
) )
// IptablesRulesLastSync is the number of iptables rules that the iptables proxy // IPTablesRulesLastSync is the number of iptables rules that the iptables proxy
// updated in the last sync. // updated in the last sync.
IptablesRulesLastSync = metrics.NewGaugeVec( IPTablesRulesLastSync = metrics.NewGaugeVec(
&metrics.GaugeOpts{ &metrics.GaugeOpts{
Subsystem: kubeProxySubsystem, Subsystem: kubeProxySubsystem,
Name: "sync_proxy_rules_iptables_last", Name: "sync_proxy_rules_iptables_last",
@ -259,17 +259,17 @@ func RegisterMetrics(mode kubeproxyconfig.ProxyMode) {
case kubeproxyconfig.ProxyModeIPTables: case kubeproxyconfig.ProxyModeIPTables:
legacyregistry.MustRegister(SyncFullProxyRulesLatency) legacyregistry.MustRegister(SyncFullProxyRulesLatency)
legacyregistry.MustRegister(SyncPartialProxyRulesLatency) legacyregistry.MustRegister(SyncPartialProxyRulesLatency)
legacyregistry.MustRegister(IptablesRestoreFailuresTotal) legacyregistry.MustRegister(IPTablesRestoreFailuresTotal)
legacyregistry.MustRegister(IptablesPartialRestoreFailuresTotal) legacyregistry.MustRegister(IPTablesPartialRestoreFailuresTotal)
legacyregistry.MustRegister(IptablesRulesTotal) legacyregistry.MustRegister(IPTablesRulesTotal)
legacyregistry.MustRegister(IptablesRulesLastSync) legacyregistry.MustRegister(IPTablesRulesLastSync)
case kubeproxyconfig.ProxyModeIPVS: case kubeproxyconfig.ProxyModeIPVS:
legacyregistry.MustRegister(IptablesRestoreFailuresTotal) legacyregistry.MustRegister(IPTablesRestoreFailuresTotal)
case kubeproxyconfig.ProxyModeNFTables: case kubeproxyconfig.ProxyModeNFTables:
// FIXME: should not use the iptables-specific metric // FIXME: should not use the iptables-specific metric
legacyregistry.MustRegister(IptablesRestoreFailuresTotal) legacyregistry.MustRegister(IPTablesRestoreFailuresTotal)
case kubeproxyconfig.ProxyModeKernelspace: case kubeproxyconfig.ProxyModeKernelspace:
// currently no winkernel-specific metrics // currently no winkernel-specific metrics

View File

@ -1620,7 +1620,7 @@ func (proxier *Proxier) syncProxyRules() {
err = proxier.nftables.Run(context.TODO(), tx) err = proxier.nftables.Run(context.TODO(), tx)
if err != nil { if err != nil {
proxier.logger.Error(err, "nftables sync failed") proxier.logger.Error(err, "nftables sync failed")
metrics.IptablesRestoreFailuresTotal.Inc() metrics.IPTablesRestoreFailuresTotal.Inc()
return return
} }
success = true success = true