-
Notifications
You must be signed in to change notification settings - Fork 486
Add golangci-lint support #895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0b267a2
8e934eb
cf58c0d
28927a3
156f2cd
aa6cea5
46b1967
568e750
067ec12
c515adc
585ac0f
41f62a0
c88c8b2
b70bac5
373008b
9447fc2
210ed96
9fe9335
6791567
127d551
4689aaf
db5a8b6
ad685f5
4c8b6a9
59d842d
2ed64eb
4f982f3
6be07fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| run: | ||
| timeout: 5m |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,6 @@ import ( | |
| ) | ||
|
|
||
| const ( | ||
| networkPolicyAnnotation = "net.beta.kubernetes.io/network-policy" | ||
| kubePodFirewallChainPrefix = "KUBE-POD-FW-" | ||
| kubeNetworkPolicyChainPrefix = "KUBE-NWPLCY-" | ||
| kubeSourceIpSetPrefix = "KUBE-SRC-" | ||
|
|
@@ -968,6 +967,9 @@ func cleanupStaleRules(activePolicyChains, activePodFwChains, activePolicyIPSets | |
|
|
||
| // find iptables chains and ipsets that are no longer used by comparing current to the active maps we were passed | ||
| chains, err := iptablesCmdHandler.ListChains("filter") | ||
| if err != nil { | ||
| return fmt.Errorf("Unable to list chains: %s", err) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @murali-reddy Is there any reason why we wouldn't want to return for all of the err conditions above too? Right now we only fatally log them, but if we can't get an valid iptables or ipset handle, I can't imagine we're going to be able to do much in this method... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The goal of this PR is to make the linter pass, I guess an issue to improve and unify error handling would be good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@aauren Yes. I belive intent is its fatal condition if we can not get a valid handle. logging FATAL message terminates the program. |
||
| } | ||
| for _, chain := range chains { | ||
| if strings.HasPrefix(chain, kubeNetworkPolicyChainPrefix) { | ||
| if _, ok := activePolicyChains[chain]; !ok { | ||
|
|
@@ -1035,7 +1037,7 @@ func cleanupStaleRules(activePolicyChains, activePodFwChains, activePolicyIPSets | |
| for podFwChain := range activePodFwChains { | ||
| podFwChainRules, err := iptablesCmdHandler.List("filter", podFwChain) | ||
| if err != nil { | ||
|
|
||
| return fmt.Errorf("Unable to list rules from the chain %s: %s", podFwChain, err) | ||
| } | ||
| for i, rule := range podFwChainRules { | ||
| if strings.Contains(rule, policyChain) { | ||
|
|
@@ -1557,6 +1559,9 @@ func (npc *NetworkPolicyController) Cleanup() { | |
| for i, rule := range forwardChainRules { | ||
| if strings.Contains(rule, kubePodFirewallChainPrefix) { | ||
| err = iptablesCmdHandler.Delete("filter", "FORWARD", strconv.Itoa(i-realRuleNo)) | ||
| if err != nil { | ||
| glog.Errorf("Failed to delete iptables rule as part of cleanup: %s", err) | ||
| } | ||
| realRuleNo++ | ||
| } | ||
| } | ||
|
|
@@ -1573,12 +1578,19 @@ func (npc *NetworkPolicyController) Cleanup() { | |
| for i, rule := range forwardChainRules { | ||
| if strings.Contains(rule, kubePodFirewallChainPrefix) { | ||
| err = iptablesCmdHandler.Delete("filter", "OUTPUT", strconv.Itoa(i-realRuleNo)) | ||
| if err != nil { | ||
| glog.Errorf("Failed to delete iptables rule as part of cleanup: %s", err) | ||
| } | ||
| realRuleNo++ | ||
| } | ||
| } | ||
|
|
||
| // flush and delete pod specific firewall chain | ||
| chains, err := iptablesCmdHandler.ListChains("filter") | ||
| if err != nil { | ||
| glog.Errorf("Unable to list chains: %s", err) | ||
| return | ||
| } | ||
| for _, chain := range chains { | ||
| if strings.HasPrefix(chain, kubePodFirewallChainPrefix) { | ||
| err = iptablesCmdHandler.ClearChain("filter", chain) | ||
|
|
@@ -1596,6 +1608,10 @@ func (npc *NetworkPolicyController) Cleanup() { | |
|
|
||
| // flush and delete per network policy specific chain | ||
| chains, err = iptablesCmdHandler.ListChains("filter") | ||
| if err != nil { | ||
| glog.Errorf("Unable to list chains: %s", err) | ||
| return | ||
| } | ||
| for _, chain := range chains { | ||
| if strings.HasPrefix(chain, kubeNetworkPolicyChainPrefix) { | ||
| err = iptablesCmdHandler.ClearChain("filter", chain) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if panic is the best way to respond here, open for suggestions.