flush iptable chains first and then remove them

while cleaning up ipvs mode. flushing iptable chains first and then
remove the chains. this avoids trying to remove chains that are still
referenced by rules in other chains.

fixes #70615
pull/564/head
Timo Derstappen 2018-11-03 11:36:14 +01:00
parent 474e27f914
commit 90d2c5ca5a
No known key found for this signature in database
GPG Key ID: 9C20AA8B0E4C15B6
1 changed files with 5 additions and 1 deletions

View File

@ -551,7 +551,7 @@ func cleanupIptablesLeftovers(ipt utiliptables.Interface) (encounteredError bool
}
}
// Flush and remove all of our chains.
// Flush and remove all of our chains. Flushing all chains before removing them also removes all links between chains first.
for _, ch := range iptablesChains {
if err := ipt.FlushChain(ch.table, ch.chain); err != nil {
if !utiliptables.IsNotFoundError(err) {
@ -559,6 +559,10 @@ func cleanupIptablesLeftovers(ipt utiliptables.Interface) (encounteredError bool
encounteredError = true
}
}
}
// Remove all of our chains.
for _, ch := range iptablesChains {
if err := ipt.DeleteChain(ch.table, ch.chain); err != nil {
if !utiliptables.IsNotFoundError(err) {
glog.Errorf("Error removing iptables rules in ipvs proxier: %v", err)