Skip to content

Commit

Permalink
LIFO order for network policies (Azure#258)
Browse files Browse the repository at this point in the history
* reverseOrder

* add npm to circleCI
  • Loading branch information
Yongli Chen authored and sharmasushant committed Oct 24, 2018
1 parent 5165403 commit 9312529
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
sudo -E env "PATH=$PATH" go test ./cni/ipam/
sudo -E env "PATH=$PATH" go test ./cnm/network/
sudo -E env "PATH=$PATH" go test ./cns/ipamclient/
sudo -E env "PATH=$PATH" go test ./npm/iptm/
sudo -E env "PATH=$PATH" go test ./npm/ipsm/
sudo -E env "PATH=$PATH" go test ./npm/
#sudo -E env "PATH=$PATH" go test ./cns/restserver/
workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion npm/iptm/iptm.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (iptMgr *IptablesManager) Add(entry *IptEntry) error {
return nil
}

iptMgr.OperationFlag = util.IptablesAppendFlag
iptMgr.OperationFlag = util.IptablesInsertionFlag
if _, err := iptMgr.Run(entry); err != nil {
log.Printf("Error creating iptables rules.\n")
return err
Expand Down
16 changes: 16 additions & 0 deletions npm/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/Azure/azure-container-networking/npm/iptm"
"github.com/Azure/azure-container-networking/telemetry"

"github.com/Azure/azure-container-networking/npm/ipsm"
"github.com/Azure/azure-container-networking/npm/util"
Expand Down Expand Up @@ -45,6 +46,11 @@ func TestAllNsList(t *testing.T) {
func TestAddNamespace(t *testing.T) {
npMgr := &NetworkPolicyManager{
nsMap: make(map[string]*namespace),
reportManager: &telemetry.ReportManager{
HostNetAgentURL: hostNetAgentURLForNpm,
ContentType: contentType,
Report: &telemetry.NPMReport{},
},
}

allNs, err := newNs(util.KubeAllNamespacesFlag)
Expand Down Expand Up @@ -81,6 +87,11 @@ func TestAddNamespace(t *testing.T) {
func TestUpdateNamespace(t *testing.T) {
npMgr := &NetworkPolicyManager{
nsMap: make(map[string]*namespace),
reportManager: &telemetry.ReportManager{
HostNetAgentURL: hostNetAgentURLForNpm,
ContentType: contentType,
Report: &telemetry.NPMReport{},
},
}

allNs, err := newNs(util.KubeAllNamespacesFlag)
Expand Down Expand Up @@ -130,6 +141,11 @@ func TestUpdateNamespace(t *testing.T) {
func TestDeleteNamespace(t *testing.T) {
npMgr := &NetworkPolicyManager{
nsMap: make(map[string]*namespace),
reportManager: &telemetry.ReportManager{
HostNetAgentURL: hostNetAgentURLForNpm,
ContentType: contentType,
Report: &telemetry.NPMReport{},
},
}

allNs, err := newNs(util.KubeAllNamespacesFlag)
Expand Down
16 changes: 16 additions & 0 deletions npm/nwpolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/Azure/azure-container-networking/npm/ipsm"
"github.com/Azure/azure-container-networking/npm/iptm"
"github.com/Azure/azure-container-networking/npm/util"
"github.com/Azure/azure-container-networking/telemetry"

corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
Expand All @@ -18,6 +19,11 @@ import (
func TestAddNetworkPolicy(t *testing.T) {
npMgr := &NetworkPolicyManager{
nsMap: make(map[string]*namespace),
reportManager: &telemetry.ReportManager{
HostNetAgentURL: hostNetAgentURLForNpm,
ContentType: contentType,
Report: &telemetry.NPMReport{},
},
}

allNs, err := newNs(util.KubeAllNamespacesFlag)
Expand Down Expand Up @@ -92,6 +98,11 @@ func TestAddNetworkPolicy(t *testing.T) {
func TestUpdateNetworkPolicy(t *testing.T) {
npMgr := &NetworkPolicyManager{
nsMap: make(map[string]*namespace),
reportManager: &telemetry.ReportManager{
HostNetAgentURL: hostNetAgentURLForNpm,
ContentType: contentType,
Report: &telemetry.NPMReport{},
},
}

allNs, err := newNs(util.KubeAllNamespacesFlag)
Expand Down Expand Up @@ -194,6 +205,11 @@ func TestUpdateNetworkPolicy(t *testing.T) {
func TestDeleteNetworkPolicy(t *testing.T) {
npMgr := &NetworkPolicyManager{
nsMap: make(map[string]*namespace),
reportManager: &telemetry.ReportManager{
HostNetAgentURL: hostNetAgentURLForNpm,
ContentType: contentType,
Report: &telemetry.NPMReport{},
},
}

allNs, err := newNs(util.KubeAllNamespacesFlag)
Expand Down
16 changes: 16 additions & 0 deletions npm/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/Azure/azure-container-networking/npm/ipsm"
"github.com/Azure/azure-container-networking/npm/util"
"github.com/Azure/azure-container-networking/telemetry"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -37,6 +38,11 @@ func TestisSystemPod(t *testing.T) {
func TestAddPod(t *testing.T) {
npMgr := &NetworkPolicyManager{
nsMap: make(map[string]*namespace),
reportManager: &telemetry.ReportManager{
HostNetAgentURL: hostNetAgentURLForNpm,
ContentType: contentType,
Report: &telemetry.NPMReport{},
},
}

allNs, err := newNs(util.KubeAllNamespacesFlag)
Expand Down Expand Up @@ -76,6 +82,11 @@ func TestAddPod(t *testing.T) {
func TestUpdatePod(t *testing.T) {
npMgr := &NetworkPolicyManager{
nsMap: make(map[string]*namespace),
reportManager: &telemetry.ReportManager{
HostNetAgentURL: hostNetAgentURLForNpm,
ContentType: contentType,
Report: &telemetry.NPMReport{},
},
}

allNs, err := newNs(util.KubeAllNamespacesFlag)
Expand Down Expand Up @@ -133,6 +144,11 @@ func TestUpdatePod(t *testing.T) {
func TestDeletePod(t *testing.T) {
npMgr := &NetworkPolicyManager{
nsMap: make(map[string]*namespace),
reportManager: &telemetry.ReportManager{
HostNetAgentURL: hostNetAgentURLForNpm,
ContentType: contentType,
Report: &telemetry.NPMReport{},
},
}

allNs, err := newNs(util.KubeAllNamespacesFlag)
Expand Down

0 comments on commit 9312529

Please sign in to comment.