mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
conditionally register nfacct metrics and ensure nfacct counters
If the nfacct sub-system is not available in the kernel then: 1. nfacct based metrics won't be registered. 2. proxier will not attempt to ensure the counters Signed-off-by: Daman Arora <aroradaman@gmail.com>
This commit is contained in:
parent
75b18b86dd
commit
33bac685a7
@ -280,7 +280,7 @@ func NewProxier(ctx context.Context,
|
||||
serviceHealthServer := healthcheck.NewServiceHealthServer(hostname, recorder, nodePortAddresses, healthzServer)
|
||||
nfacctRunner, err := nfacct.New()
|
||||
if err != nil {
|
||||
logger.Error(err, "Failed to create nfacct runner")
|
||||
logger.Error(err, "Failed to create nfacct runner, nfacct based metrics won't be available")
|
||||
}
|
||||
|
||||
proxier := &Proxier{
|
||||
|
@ -299,8 +299,12 @@ func RegisterMetrics(mode kubeproxyconfig.ProxyMode) {
|
||||
|
||||
switch mode {
|
||||
case kubeproxyconfig.ProxyModeIPTables:
|
||||
if iptablesCTStateInvalidDroppedMetricCollector != nil {
|
||||
legacyregistry.CustomMustRegister(iptablesCTStateInvalidDroppedMetricCollector)
|
||||
}
|
||||
if localhostNodePortsAcceptedMetricsCollector != nil {
|
||||
legacyregistry.CustomMustRegister(localhostNodePortsAcceptedMetricsCollector)
|
||||
}
|
||||
legacyregistry.MustRegister(SyncFullProxyRulesLatency)
|
||||
legacyregistry.MustRegister(SyncPartialProxyRulesLatency)
|
||||
legacyregistry.MustRegister(IPTablesRestoreFailuresTotal)
|
||||
@ -332,6 +336,7 @@ func newNFAcctMetricCollector(counter string, description *metrics.Desc) *nfacct
|
||||
client, err := nfacct.New()
|
||||
if err != nil {
|
||||
klog.ErrorS(err, "failed to initialize nfacct client")
|
||||
return nil
|
||||
}
|
||||
return &nfacctMetricCollector{
|
||||
client: client,
|
||||
|
Loading…
Reference in New Issue
Block a user