mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
Merge pull request #117787 from danwinship/iptables-restore-metrics
Add new partial/full sync time metrics for iptables kube-proxy
This commit is contained in:
commit
f418411d0f
@ -779,14 +779,20 @@ func (proxier *Proxier) syncProxyRules() {
|
||||
return
|
||||
}
|
||||
|
||||
tryPartialSync := !proxier.needFullSync && utilfeature.DefaultFeatureGate.Enabled(features.MinimizeIPTablesRestore)
|
||||
|
||||
// Keep track of how long syncs take.
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
metrics.SyncProxyRulesLatency.Observe(metrics.SinceInSeconds(start))
|
||||
if tryPartialSync {
|
||||
metrics.SyncPartialProxyRulesLatency.Observe(metrics.SinceInSeconds(start))
|
||||
} else {
|
||||
metrics.SyncFullProxyRulesLatency.Observe(metrics.SinceInSeconds(start))
|
||||
}
|
||||
klog.V(2).InfoS("SyncProxyRules complete", "elapsed", time.Since(start))
|
||||
}()
|
||||
|
||||
tryPartialSync := !proxier.needFullSync && utilfeature.DefaultFeatureGate.Enabled(features.MinimizeIPTablesRestore)
|
||||
var serviceChanged, endpointsChanged sets.Set[string]
|
||||
if tryPartialSync {
|
||||
serviceChanged = proxier.serviceChanges.PendingChanges()
|
||||
|
@ -28,6 +28,8 @@ const kubeProxySubsystem = "kubeproxy"
|
||||
|
||||
var (
|
||||
// SyncProxyRulesLatency is the latency of one round of kube-proxy syncing proxy rules.
|
||||
// (With the iptables proxy, if MinimizeIPTablesRestore is enabled, this includes both
|
||||
// full and partial syncs.)
|
||||
SyncProxyRulesLatency = metrics.NewHistogram(
|
||||
&metrics.HistogramOpts{
|
||||
Subsystem: kubeProxySubsystem,
|
||||
@ -38,6 +40,30 @@ var (
|
||||
},
|
||||
)
|
||||
|
||||
// SyncFullProxyRulesLatency is the latency of one round of full rule syncing, when
|
||||
// MinimizeIPTablesRestore is enabled.
|
||||
SyncFullProxyRulesLatency = metrics.NewHistogram(
|
||||
&metrics.HistogramOpts{
|
||||
Subsystem: kubeProxySubsystem,
|
||||
Name: "sync_full_proxy_rules_duration_seconds",
|
||||
Help: "SyncProxyRules latency in seconds for full resyncs",
|
||||
Buckets: metrics.ExponentialBuckets(0.001, 2, 15),
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
)
|
||||
|
||||
// SyncPartialProxyRulesLatency is the latency of one round of partial rule syncing, when
|
||||
// MinimizeIPTablesRestore is enabled.
|
||||
SyncPartialProxyRulesLatency = metrics.NewHistogram(
|
||||
&metrics.HistogramOpts{
|
||||
Subsystem: kubeProxySubsystem,
|
||||
Name: "sync_partial_proxy_rules_duration_seconds",
|
||||
Help: "SyncProxyRules latency in seconds for partial resyncs",
|
||||
Buckets: metrics.ExponentialBuckets(0.001, 2, 15),
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
)
|
||||
|
||||
// SyncProxyRulesLastTimestamp is the timestamp proxy rules were last
|
||||
// successfully synced.
|
||||
SyncProxyRulesLastTimestamp = metrics.NewGauge(
|
||||
@ -180,6 +206,8 @@ var registerMetricsOnce sync.Once
|
||||
func RegisterMetrics() {
|
||||
registerMetricsOnce.Do(func() {
|
||||
legacyregistry.MustRegister(SyncProxyRulesLatency)
|
||||
legacyregistry.MustRegister(SyncFullProxyRulesLatency)
|
||||
legacyregistry.MustRegister(SyncPartialProxyRulesLatency)
|
||||
legacyregistry.MustRegister(SyncProxyRulesLastTimestamp)
|
||||
legacyregistry.MustRegister(NetworkProgrammingLatency)
|
||||
legacyregistry.MustRegister(EndpointChangesPending)
|
||||
|
Loading…
Reference in New Issue
Block a user