Skip to content

Commit 0b1086b

Browse files
authored
Fixing a regression with integration of two controllers (#842)
1 parent a7b5202 commit 0b1086b

File tree

4 files changed

+13
-33
lines changed

4 files changed

+13
-33
lines changed

npm/nameSpaceController_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,6 @@ func (f *nameSpaceFixture) ipSetRestore(ipsetConfigFile string) {
8787
f.t.Errorf("TestAddPod failed @ ipsMgr.Restore")
8888
}
8989
}
90-
func newNPMgr(t *testing.T) *NetworkPolicyManager {
91-
npMgr := &NetworkPolicyManager{
92-
NsMap: make(map[string]*Namespace),
93-
PodMap: make(map[string]*NpmPod),
94-
TelemetryEnabled: false,
95-
}
96-
97-
// This initialization important as without this NPM will panic
98-
allNs, _ := newNs(util.KubeAllNamespacesFlag)
99-
npMgr.NsMap[util.KubeAllNamespacesFlag] = allNs
100-
return npMgr
101-
}
10290

10391
func newNameSpace(name, rv string, labels map[string]string) *corev1.Namespace {
10492
return &corev1.Namespace{

npm/npm.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/Azure/azure-container-networking/npm/metrics"
1717
"github.com/Azure/azure-container-networking/npm/util"
1818
"github.com/Azure/azure-container-networking/telemetry"
19-
corev1 "k8s.io/api/core/v1"
2019
networkingv1 "k8s.io/api/networking/v1"
2120
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2221
"k8s.io/apimachinery/pkg/version"

npm/npm_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ import (
1010
"github.com/Azure/azure-container-networking/npm/util"
1111
)
1212

13+
func newNPMgr(t *testing.T) *NetworkPolicyManager {
14+
npMgr := &NetworkPolicyManager{
15+
NsMap: make(map[string]*Namespace),
16+
PodMap: make(map[string]*NpmPod),
17+
TelemetryEnabled: false,
18+
}
19+
20+
// This initialization important as without this NPM will panic
21+
allNs, _ := newNs(util.KubeAllNamespacesFlag)
22+
npMgr.NsMap[util.KubeAllNamespacesFlag] = allNs
23+
return npMgr
24+
}
25+
1326
func TestMain(m *testing.M) {
1427
metrics.InitializeAll()
1528
iptMgr := iptm.NewIptablesManager()

npm/podController_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import (
66
"fmt"
77
"strconv"
88
"testing"
9-
"time"
109

1110
"github.com/Azure/azure-container-networking/npm/ipsm"
12-
"github.com/Azure/azure-container-networking/npm/util"
1311
corev1 "k8s.io/api/core/v1"
1412

1513
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -20,11 +18,6 @@ import (
2018
"k8s.io/client-go/tools/cache"
2119
)
2220

23-
var (
24-
alwaysReady = func() bool { return true }
25-
noResyncPeriodFunc = func() time.Duration { return 0 }
26-
)
27-
2821
const (
2922
HostNetwork = true
3023
NonHostNetwork = false
@@ -88,19 +81,6 @@ func (f *podFixture) ipSetRestore(ipsetConfigFile string) {
8881
}
8982
}
9083

91-
func newNPMgr(t *testing.T) *NetworkPolicyManager {
92-
npMgr := &NetworkPolicyManager{
93-
NsMap: make(map[string]*Namespace),
94-
PodMap: make(map[string]*NpmPod),
95-
}
96-
97-
// (TODO:) should remove error return
98-
// (Question) Is it necessary? Seems that it is necessary. Without this, it will have panic in PodController
99-
allNs, _ := newNs(util.KubeAllNamespacesFlag)
100-
npMgr.NsMap[util.KubeAllNamespacesFlag] = allNs
101-
return npMgr
102-
}
103-
10484
func createPod(name, ns, rv, podIP string, labels map[string]string, isHostNewtwork bool, podPhase corev1.PodPhase) *corev1.Pod {
10585
return &corev1.Pod{
10686
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)