Skip to content

Commit

Permalink
[backport] fix: [NPM] [Linux] handle more than 15 leaked ipsets (#2998)
Browse files Browse the repository at this point in the history
Signed-off-by: Hunter Gregory <[email protected]>
  • Loading branch information
huntergregory committed Sep 11, 2024
1 parent 609e6ee commit 051f02e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions npm/pkg/dataplane/ipsets/ipsetmanager_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,15 @@ func (iMgr *IPSetManager) setsWithReferences() map[string]struct{} {
var setsWithReferences map[string]struct{}
if haveRefsStill {
setsWithReferences = readByteLinesToMap(setsWithReferencesBytes)
subset := make(map[string]struct{}, maxLinesToPrint)
for key := range setsWithReferences {
subset[key] = struct{}{}
if len(subset) >= maxLinesToPrint {
break
}
}
metrics.SendErrorLogAndMetric(util.IpsmID, "error: found leaked reference counts in kernel. ipsets (max %d): %+v. err: %v",
maxLinesToPrint, setsWithReferences, err)
maxLinesToPrint, subset, err)
}

return setsWithReferences
Expand Down Expand Up @@ -847,9 +854,6 @@ func readByteLinesToMap(output []byte) map[string]struct{} {
line, readIndex = parse.Line(readIndex, output)
hashedSetName := strings.Trim(string(line), "\n")
lines[hashedSetName] = struct{}{}
if len(lines) > maxLinesToPrint {
break
}
}
return lines
}

0 comments on commit 051f02e

Please sign in to comment.