Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
e1837185
Commit
e1837185
authored
Oct 27, 2015
by
Avesh Agarwal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves iptables cleanup for pure iptables based proxier.
parent
fd6daea0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
proxier.go
pkg/proxy/iptables/proxier.go
+22
-1
No files found.
pkg/proxy/iptables/proxier.go
View file @
e1837185
...
@@ -188,7 +188,7 @@ func NewProxier(ipt utiliptables.Interface, exec utilexec.Interface, syncPeriod
...
@@ -188,7 +188,7 @@ func NewProxier(ipt utiliptables.Interface, exec utilexec.Interface, syncPeriod
// It returns true if an error was encountered. Errors are logged.
// It returns true if an error was encountered. Errors are logged.
func
CleanupLeftovers
(
ipt
utiliptables
.
Interface
)
(
encounteredError
bool
)
{
func
CleanupLeftovers
(
ipt
utiliptables
.
Interface
)
(
encounteredError
bool
)
{
//TODO: actually tear down all rules and chains.
//TODO: actually tear down all rules and chains.
args
:=
[]
string
{
"-
j"
,
"KUBE-SERVICES"
}
args
:=
[]
string
{
"-
m"
,
"comment"
,
"--comment"
,
"kubernetes service portals"
,
"-j"
,
string
(
iptablesServicesChain
)
}
if
err
:=
ipt
.
DeleteRule
(
utiliptables
.
TableNAT
,
utiliptables
.
ChainOutput
,
args
...
);
err
!=
nil
{
if
err
:=
ipt
.
DeleteRule
(
utiliptables
.
TableNAT
,
utiliptables
.
ChainOutput
,
args
...
);
err
!=
nil
{
glog
.
Errorf
(
"Error removing pure-iptables proxy rule: %v"
,
err
)
glog
.
Errorf
(
"Error removing pure-iptables proxy rule: %v"
,
err
)
encounteredError
=
true
encounteredError
=
true
...
@@ -197,6 +197,27 @@ func CleanupLeftovers(ipt utiliptables.Interface) (encounteredError bool) {
...
@@ -197,6 +197,27 @@ func CleanupLeftovers(ipt utiliptables.Interface) (encounteredError bool) {
glog
.
Errorf
(
"Error removing pure-iptables proxy rule: %v"
,
err
)
glog
.
Errorf
(
"Error removing pure-iptables proxy rule: %v"
,
err
)
encounteredError
=
true
encounteredError
=
true
}
}
args
=
[]
string
{
"-m"
,
"comment"
,
"--comment"
,
"kubernetes service traffic requiring SNAT"
,
"-m"
,
"mark"
,
"--mark"
,
iptablesMasqueradeMark
,
"-j"
,
"MASQUERADE"
}
if
err
:=
ipt
.
DeleteRule
(
utiliptables
.
TableNAT
,
utiliptables
.
ChainPostrouting
,
args
...
);
err
!=
nil
{
glog
.
Errorf
(
"Error removing pure-iptables proxy rule: %v"
,
err
)
encounteredError
=
true
}
// flush and delete chains.
chains
:=
[]
utiliptables
.
Chain
{
iptablesServicesChain
,
iptablesNodePortsChain
}
for
_
,
c
:=
range
chains
{
// flush chain, then if sucessful delete, delete will fail if flush fails.
if
err
:=
ipt
.
FlushChain
(
utiliptables
.
TableNAT
,
c
);
err
!=
nil
{
glog
.
Errorf
(
"Error flushing pure-iptables proxy chain: %v"
,
err
)
encounteredError
=
true
}
else
{
if
err
=
ipt
.
DeleteChain
(
utiliptables
.
TableNAT
,
c
);
err
!=
nil
{
glog
.
Errorf
(
"Error deleting pure-iptables proxy chain: %v"
,
err
)
encounteredError
=
true
}
}
}
return
encounteredError
return
encounteredError
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment