-
Notifications
You must be signed in to change notification settings - Fork 260
scale: [NPM] ignore leaked ipset references #1502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| grepCommand := iMgr.ioShim.Exec.Command(ioutil.Grep, azureNPMPrefix) | ||
| azureIPSets, haveAzureIPSets, commandError := ioutil.PipeCommandToGrep(listCommand, grepCommand) | ||
| klog.Infof("running this command while resetting ipsets: [%s %s %s | %s %s]", ipsetCommand, ipsetListFlag, ipsetNameFlag, ioutil.Grep, azureNPMRegex) | ||
| azureIPSets, haveAzureIPSets, commandError := ioutil.PipeCommandToGrep(listNamesCommand, grepCommand) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an extra check here ? if the total number of IPSets == IPSets with azure-npm- prefix, then wouldn't it be easy to just call in generic ipset flush and destroy ?
i am afraid there might some cases i am missing here, or have some weird scenario in linux which we are not thinking of. Wdyt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ipset list --names | grep -v azurenpmregex == 0
ipset flush && ipset destroy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| grepCommand := iMgr.ioShim.Exec.Command(ioutil.Grep, ioutil.GrepQuietFlag, ioutil.GrepAntiMatchFlag, azureNPMPrefix) | ||
| commandString := fmt.Sprintf(" [%s %s %s | %s %s %s %s]", ipsetCommand, ipsetListFlag, ipsetNameFlag, ioutil.Grep, ioutil.GrepQuietFlag, ioutil.GrepAntiMatchFlag, azureNPMPrefix) | ||
| klog.Infof("running this command while resetting ipsets: [%s]", commandString) | ||
| _, haveNonAzureIPSets, commandError := ioutil.PipeCommandToGrep(listNamesCommand, grepCommand) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: haveNonAzureIPSets -> haveNonAzureNPMIPSets
matmerr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
marking for posterity that would like to steer away from all the grep/piping/exit code redirection, opt for something more built in
Sometimes at high scale, the Linux ipset utility will leak reference counts for ipsets e.g. there will be no iptables rules or lists referencing an ipset, yet it will have a positive reference count. As a result, some lingering ipsets can't be deleted when NPM boots up.
In NPM "v1", we ignore these in-use-by-kernel errors. Now we do the same in "v2" to prevent a CrashLoopBackOff when this kernel leak happens.