@@ -727,14 +727,14 @@ func (proxier *Proxier) deleteEndpointConnections(connectionMap []proxy.ServiceE
727
727
const endpointChainsNumberThreshold = 1000
728
728
729
729
// Assumes proxier.mu is held.
730
- func (proxier * Proxier ) appendServiceCommentLocked (args []string , svcName string ) {
730
+ func (proxier * Proxier ) appendServiceCommentLocked (args []string , svcName string ) [] string {
731
731
// Not printing these comments, can reduce size of iptables (in case of large
732
732
// number of endpoints) even by 40%+. So if total number of endpoint chains
733
733
// is large enough, we simply drop those comments.
734
734
if proxier .endpointChainsNumber > endpointChainsNumberThreshold {
735
- return
735
+ return args
736
736
}
737
- args = append (args , "-m" , "comment" , "--comment" , svcName )
737
+ return append (args , "-m" , "comment" , "--comment" , svcName )
738
738
}
739
739
740
740
// This is where all of the iptables-save/restore calls happen.
@@ -1266,7 +1266,7 @@ func (proxier *Proxier) syncProxyRules() {
1266
1266
args = append (args [:0 ],
1267
1267
"-A" , string (svcChain ),
1268
1268
)
1269
- proxier .appendServiceCommentLocked (args , svcNameString )
1269
+ args = proxier .appendServiceCommentLocked (args , svcNameString )
1270
1270
args = append (args ,
1271
1271
"-m" , "recent" , "--name" , string (endpointChain ),
1272
1272
"--rcheck" , "--seconds" , strconv .Itoa (svcInfo .StickyMaxAgeSeconds ()), "--reap" ,
@@ -1278,13 +1278,10 @@ func (proxier *Proxier) syncProxyRules() {
1278
1278
1279
1279
// Now write loadbalancing & DNAT rules.
1280
1280
n := len (endpointChains )
1281
- localEndpoints := make ([]* endpointsInfo , 0 )
1282
1281
localEndpointChains := make ([]utiliptables.Chain , 0 )
1283
1282
for i , endpointChain := range endpointChains {
1284
1283
// Write ingress loadbalancing & DNAT rules only for services that request OnlyLocal traffic.
1285
1284
if svcInfo .OnlyNodeLocalEndpoints () && endpoints [i ].IsLocal {
1286
- // These slices parallel each other; must be kept in sync
1287
- localEndpoints = append (localEndpoints , endpoints [i ])
1288
1285
localEndpointChains = append (localEndpointChains , endpointChains [i ])
1289
1286
}
1290
1287
@@ -1296,7 +1293,7 @@ func (proxier *Proxier) syncProxyRules() {
1296
1293
1297
1294
// Balancing rules in the per-service chain.
1298
1295
args = append (args [:0 ], "-A" , string (svcChain ))
1299
- proxier .appendServiceCommentLocked (args , svcNameString )
1296
+ args = proxier .appendServiceCommentLocked (args , svcNameString )
1300
1297
if i < (n - 1 ) {
1301
1298
// Each rule is a probabilistic match.
1302
1299
args = append (args ,
@@ -1310,7 +1307,7 @@ func (proxier *Proxier) syncProxyRules() {
1310
1307
1311
1308
// Rules in the per-endpoint chain.
1312
1309
args = append (args [:0 ], "-A" , string (endpointChain ))
1313
- proxier .appendServiceCommentLocked (args , svcNameString )
1310
+ args = proxier .appendServiceCommentLocked (args , svcNameString )
1314
1311
// Handle traffic that loops back to the originator with SNAT.
1315
1312
writeLine (proxier .natRules , append (args ,
1316
1313
"-s" , utilproxy .ToCIDR (net .ParseIP (epIP )),
0 commit comments