@@ -40,6 +40,7 @@ import (
40
40
"k8s.io/apimachinery/pkg/util/sets"
41
41
utilfeature "k8s.io/apiserver/pkg/util/feature"
42
42
featuregatetesting "k8s.io/component-base/featuregate/testing"
43
+ "k8s.io/component-base/metrics/legacyregistry"
43
44
"k8s.io/component-base/metrics/testutil"
44
45
"k8s.io/klog/v2"
45
46
"k8s.io/kubernetes/pkg/features"
@@ -6150,6 +6151,7 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
6150
6151
ipt := iptablestest .NewFake ()
6151
6152
fp := NewFakeProxier (ipt )
6152
6153
metrics .RegisterMetrics ()
6154
+ defer legacyregistry .Reset ()
6153
6155
6154
6156
// Create initial state
6155
6157
var svc2 * v1.Service
@@ -6677,11 +6679,11 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
6677
6679
if fp .needFullSync {
6678
6680
t .Fatalf ("Proxier unexpectedly already needs a full sync?" )
6679
6681
}
6680
- prFailures , err := testutil .GetCounterMetricValue (metrics .IptablesPartialRestoreFailuresTotal )
6682
+ partialRestoreFailures , err := testutil .GetCounterMetricValue (metrics .IptablesPartialRestoreFailuresTotal )
6681
6683
if err != nil {
6682
6684
t .Fatalf ("Could not get partial restore failures metric: %v" , err )
6683
6685
}
6684
- if prFailures != 0.0 {
6686
+ if partialRestoreFailures != 0.0 {
6685
6687
t .Errorf ("Already did a partial resync? Something failed earlier!" )
6686
6688
}
6687
6689
@@ -6711,12 +6713,12 @@ func TestSyncProxyRulesRepeated(t *testing.T) {
6711
6713
if ! fp .needFullSync {
6712
6714
t .Errorf ("Proxier did not fail on previous partial resync?" )
6713
6715
}
6714
- updatedPRFailures , err := testutil .GetCounterMetricValue (metrics .IptablesPartialRestoreFailuresTotal )
6716
+ updatedPartialRestoreFailures , err := testutil .GetCounterMetricValue (metrics .IptablesPartialRestoreFailuresTotal )
6715
6717
if err != nil {
6716
6718
t .Errorf ("Could not get partial restore failures metric: %v" , err )
6717
6719
}
6718
- if updatedPRFailures != prFailures + 1.0 {
6719
- t .Errorf ("Partial restore failures metric was not incremented after failed partial resync (expected %.02f, got %.02f)" , prFailures + 1.0 , updatedPRFailures )
6720
+ if updatedPartialRestoreFailures != partialRestoreFailures + 1.0 {
6721
+ t .Errorf ("Partial restore failures metric was not incremented after failed partial resync (expected %.02f, got %.02f)" , partialRestoreFailures + 1.0 , updatedPartialRestoreFailures )
6720
6722
}
6721
6723
6722
6724
// On retry we should do a full resync, which should succeed (and delete svc4)
0 commit comments