proxy/metrics: refactor nfacct metrics

Signed-off-by: Daman Arora <aroradaman@gmail.com>
This commit is contained in:
Daman Arora 2024-08-27 23:15:03 +05:30
parent 09596a57de
commit 6c5dac89bc

View File

@ -148,7 +148,6 @@ var (
"packets dropped by iptables to work around conntrack problems",
nil, nil, metrics.ALPHA, "")
IPTablesCTStateInvalidDroppedNFAcctCounter = "ct_state_invalid_dropped_pkts"
iptablesCTStateInvalidDroppedMetricCollector = newNFAcctMetricCollector(IPTablesCTStateInvalidDroppedNFAcctCounter, iptablesCTStateInvalidDroppedPacketsDescription)
// IPTablesRestoreFailuresTotal is the number of iptables restore failures that the proxy has
// seen.
@ -274,7 +273,6 @@ var (
"Number of packets accepted on nodeports of loopback interface",
nil, nil, metrics.ALPHA, "")
LocalhostNodePortAcceptedNFAcctCounter = "localhost_nps_accepted_pkts"
localhostNodePortsAcceptedMetricsCollector = newNFAcctMetricCollector(LocalhostNodePortAcceptedNFAcctCounter, localhostNodePortsAcceptedPacketsDescription)
)
var registerMetricsOnce sync.Once
@ -299,9 +297,11 @@ func RegisterMetrics(mode kubeproxyconfig.ProxyMode) {
switch mode {
case kubeproxyconfig.ProxyModeIPTables:
iptablesCTStateInvalidDroppedMetricCollector := newNFAcctMetricCollector(IPTablesCTStateInvalidDroppedNFAcctCounter, iptablesCTStateInvalidDroppedPacketsDescription)
if iptablesCTStateInvalidDroppedMetricCollector != nil {
legacyregistry.CustomMustRegister(iptablesCTStateInvalidDroppedMetricCollector)
}
localhostNodePortsAcceptedMetricsCollector := newNFAcctMetricCollector(LocalhostNodePortAcceptedNFAcctCounter, localhostNodePortsAcceptedPacketsDescription)
if localhostNodePortsAcceptedMetricsCollector != nil {
legacyregistry.CustomMustRegister(localhostNodePortsAcceptedMetricsCollector)
}