Skip to content

Commit

Permalink
Merge pull request #931 from cloudnativelabs/pr914-feedback
Browse files Browse the repository at this point in the history
avoide listing a chain if the rule already exists
  • Loading branch information
aauren authored Jun 16, 2020
2 parents 309c803 + 1bec864 commit 4f9a794
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/controllers/netpol/network_policy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,6 @@ func (npc *NetworkPolicyController) ensureTopLevelChains() {
}

ensureRuleAtposition := func(chain string, ruleSpec []string, position int) {
rules, err := iptablesCmdHandler.List("filter", chain)
if err != nil {
glog.Fatalf("failed to list rules in filter table %s chain due to %s", chain, err.Error())
}

exists, err := iptablesCmdHandler.Exists("filter", chain, ruleSpec...)
if err != nil {
glog.Fatalf("Failed to verify rule exists in %s chain due to %s", chain, err.Error())
Expand All @@ -216,6 +211,11 @@ func (npc *NetworkPolicyController) ensureTopLevelChains() {
}
return
}
rules, err := iptablesCmdHandler.List("filter", chain)
if err != nil {
glog.Fatalf("failed to list rules in filter table %s chain due to %s", chain, err.Error())
}

var ruleNo int
for i, rule := range rules {
rule = strings.Replace(rule, "\"", "", 2) //removes quote from comment string
Expand Down

0 comments on commit 4f9a794

Please sign in to comment.