Skip to content

Commit d57e6c5

Browse files
[backport] fix: [NPM] [Linux] handle more than 15 leaked ipsets (#3007)
[backport] fix: [NPM] [Linux] handle more than 15 leaked ipsets (#2998) Signed-off-by: Hunter Gregory <[email protected]>
1 parent 654fad3 commit d57e6c5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

npm/pkg/dataplane/ipsets/ipsetmanager_linux.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,15 @@ func (iMgr *IPSetManager) setsWithReferences() map[string]struct{} {
229229
var setsWithReferences map[string]struct{}
230230
if haveRefsStill {
231231
setsWithReferences = readByteLinesToMap(setsWithReferencesBytes)
232+
subset := make(map[string]struct{}, maxLinesToPrint)
233+
for key := range setsWithReferences {
234+
subset[key] = struct{}{}
235+
if len(subset) >= maxLinesToPrint {
236+
break
237+
}
238+
}
232239
metrics.SendErrorLogAndMetric(util.IpsmID, "error: found leaked reference counts in kernel. ipsets (max %d): %+v. err: %v",
233-
maxLinesToPrint, setsWithReferences, err)
240+
maxLinesToPrint, subset, err)
234241
}
235242

236243
return setsWithReferences
@@ -847,9 +854,6 @@ func readByteLinesToMap(output []byte) map[string]struct{} {
847854
line, readIndex = parse.Line(readIndex, output)
848855
hashedSetName := strings.Trim(string(line), "\n")
849856
lines[hashedSetName] = struct{}{}
850-
if len(lines) > maxLinesToPrint {
851-
break
852-
}
853857
}
854858
return lines
855859
}

0 commit comments

Comments
 (0)