Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion npm/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var npmV2DataplaneCfg = &dataplane.Config{
NetworkName: "azure", // FIXME should be specified in DP config instead
},
PolicyManagerCfg: &policies.PolicyManagerCfg{
Mode: policies.IPSetPolicyMode,
PolicyMode: policies.IPSetPolicyMode,
},
}

Expand Down
2 changes: 1 addition & 1 deletion npm/pkg/dataplane/dataplane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
NetworkName: "azure",
},
PolicyManagerCfg: &policies.PolicyManagerCfg{
Mode: policies.IPSetPolicyMode,
PolicyMode: policies.IPSetPolicyMode,
},
}

Expand Down
15 changes: 6 additions & 9 deletions npm/pkg/dataplane/dataplane_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,22 @@ import (
)

const (
policyWithSets policyMode = "policyWithSets"
policyWithIPs policyMode = "policyWithIPs"
maxNoNetRetryCount int = 240 // max wait time 240*5 == 20 mins
maxNoNetSleepTime int = 5 // in seconds
maxNoNetRetryCount int = 240 // max wait time 240*5 == 20 mins
maxNoNetSleepTime int = 5 // in seconds
)

func (dp *DataPlane) setPolicyMode() {
dp.policyMode = policyWithSets
dp.PolicyMode = policies.IPSetPolicyMode
err := hcn.SetPolicySupported()
if err != nil {
dp.policyMode = policyWithIPs
dp.PolicyMode = policies.IPPolicyMode
}
}

// initializeDataPlane will help gather network and endpoint details
func (dp *DataPlane) initializeDataPlane() error {
klog.Infof("[DataPlane] Initializing dataplane for windows")
// policy mode is only needed for windows, move this to a more central position.
if dp.policyMode == "" {
if dp.PolicyMode == "" {
dp.setPolicyMode()
}

Expand Down Expand Up @@ -82,7 +79,7 @@ func (dp *DataPlane) bootupDataPlane() error {
epIDs := dp.getAllEndpointIDs()

// It is important to keep order to clean-up ACLs before ipsets. Otherwise we won't be able to delete ipsets referenced by ACLs
if err := dp.policyMgr.Reset(epIDs); err != nil {
if err := dp.policyMgr.Bootup(epIDs); err != nil {
return npmerrors.ErrorWrapper(npmerrors.ResetDataPlane, false, "failed to reset policy dataplane", err)
}
if err := dp.ipsetMgr.ResetIPSets(); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion npm/pkg/dataplane/policies/policymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const (
)

type PolicyManagerCfg struct {
Mode PolicyManagerMode
// PolicyMode only affects Windows
PolicyMode PolicyManagerMode
}

type PolicyMap struct {
Expand Down
2 changes: 1 addition & 1 deletion npm/pkg/dataplane/policies/policymanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

var (
ipsetConfig = &PolicyManagerCfg{
Mode: IPSetPolicyMode,
PolicyMode: IPSetPolicyMode,
}

// below epList is no-op for linux
Expand Down
5 changes: 4 additions & 1 deletion npm/pkg/dataplane/policies/policymanager_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ func getPMgr(t *testing.T) (*PolicyManager, *hnswrapper.Hnsv2wrapperFake) {
_, err := hns.CreateEndpoint(ep)
require.NoError(t, err)
}
return NewPolicyManager(io, IpsetAndNoRebootConfig), hns
cfg := &PolicyManagerCfg{
PolicyMode: IPSetPolicyMode,
}
return NewPolicyManager(io, cfg), hns
}

func verifyFakeHNSCacheACLs(t *testing.T, expected, actual []*hnswrapper.FakeEndpointPolicy) bool {
Expand Down
6 changes: 1 addition & 5 deletions npm/pkg/dataplane/policies/testutils_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ func GetRemovePolicyTestCalls(_ *NPMNetworkPolicy) []testutils.TestCmd {
return []testutils.TestCmd{}
}

func GetInitializeTestCalls() []testutils.TestCmd {
return []testutils.TestCmd{}
}

func GetResetTestCalls() []testutils.TestCmd {
func GetBootupTestCalls() []testutils.TestCmd {
return []testutils.TestCmd{}
}
2 changes: 1 addition & 1 deletion test/integration/npm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
NetworkName: "azure",
},
PolicyManagerCfg: &policies.PolicyManagerCfg{
Mode: policies.IPSetPolicyMode,
PolicyMode: policies.IPSetPolicyMode,
},
}

Expand Down